Date: Sat, 12 Oct 2019 19:03:07 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r353454 - head/sys/kern Message-ID: <201910121903.x9CJ37N5026383@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Sat Oct 12 19:03:07 2019 New Revision: 353454 URL: https://svnweb.freebsd.org/changeset/base/353454 Log: Allocate device softc from the device domain. Since we are trying to bind device interrupt threads to the device domain, it should have sense to make memory often accessed by them local. If domain is not known, fall back to round-robin. MFC after: 2 weeks Sponsored by: iXsystems, Inc. Modified: head/sys/kern/subr_bus.c Modified: head/sys/kern/subr_bus.c ============================================================================== --- head/sys/kern/subr_bus.c Sat Oct 12 18:18:11 2019 (r353453) +++ head/sys/kern/subr_bus.c Sat Oct 12 19:03:07 2019 (r353454) @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/conf.h> +#include <sys/domainset.h> #include <sys/eventhandler.h> #include <sys/filio.h> #include <sys/lock.h> @@ -2541,7 +2542,7 @@ void device_set_softc(device_t dev, void *softc) { if (dev->softc && !(dev->flags & DF_EXTERNALSOFTC)) - free(dev->softc, M_BUS_SC); + free_domain(dev->softc, M_BUS_SC); dev->softc = softc; if (dev->softc) dev->flags |= DF_EXTERNALSOFTC; @@ -2558,7 +2559,7 @@ device_set_softc(device_t dev, void *softc) void device_free_softc(void *softc) { - free(softc, M_BUS_SC); + free_domain(softc, M_BUS_SC); } /** @@ -2817,6 +2818,9 @@ device_is_devclass_fixed(device_t dev) int device_set_driver(device_t dev, driver_t *driver) { + int domain; + struct domainset *policy; + if (dev->state >= DS_ATTACHED) return (EBUSY); @@ -2824,7 +2828,7 @@ device_set_driver(device_t dev, driver_t *driver) return (0); if (dev->softc && !(dev->flags & DF_EXTERNALSOFTC)) { - free(dev->softc, M_BUS_SC); + free_domain(dev->softc, M_BUS_SC); dev->softc = NULL; } device_set_desc(dev, NULL); @@ -2833,8 +2837,12 @@ device_set_driver(device_t dev, driver_t *driver) if (driver) { kobj_init((kobj_t) dev, (kobj_class_t) driver); if (!(dev->flags & DF_EXTERNALSOFTC) && driver->size > 0) { - dev->softc = malloc(driver->size, M_BUS_SC, - M_NOWAIT | M_ZERO); + if (bus_get_domain(dev, &domain) == 0) + policy = DOMAINSET_PREF(domain); + else + policy = DOMAINSET_RR(); + dev->softc = malloc_domainset(driver->size, M_BUS_SC, + policy, M_NOWAIT | M_ZERO); if (!dev->softc) { kobj_delete((kobj_t) dev, NULL); kobj_init((kobj_t) dev, &null_class);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910121903.x9CJ37N5026383>