Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 28 Sep 2019 00:59:39 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r352827 - stable/12/sys/dev/ioat
Message-ID:  <201909280059.x8S0xdV8052904@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Sat Sep 28 00:59:39 2019
New Revision: 352827
URL: https://svnweb.freebsd.org/changeset/base/352827

Log:
  MFC r352544: Improve ioat(4) NUMA-awareness.
  
  Allocate ioat->ring memory from the device domain.
  Schedule ioat->poll_timer to the first CPU of the device domain.
  
  According to pcm-numa tool from intel-pcm port, this reduces number of
  remote DRAM accesses while copying data by 75%.  And unless it is a noise,
  I've noticed some speed improvement when copying data to other domain.

Modified:
  stable/12/sys/dev/ioat/ioat.c
  stable/12/sys/dev/ioat/ioat_internal.h
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/dev/ioat/ioat.c
==============================================================================
--- stable/12/sys/dev/ioat/ioat.c	Fri Sep 27 23:37:01 2019	(r352826)
+++ stable/12/sys/dev/ioat/ioat.c	Sat Sep 28 00:59:39 2019	(r352827)
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/bus.h>
 #include <sys/conf.h>
+#include <sys/domainset.h>
 #include <sys/fail.h>
 #include <sys/ioccom.h>
 #include <sys/kernel.h>
@@ -43,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 #include <sys/rman.h>
 #include <sys/sbuf.h>
+#include <sys/smp.h>
 #include <sys/sysctl.h>
 #include <sys/taskqueue.h>
 #include <sys/time.h>
@@ -265,6 +267,11 @@ ioat_attach(device_t device)
 
 	ioat = DEVICE2SOFTC(device);
 	ioat->device = device;
+	if (bus_get_domain(device, &ioat->domain) != 0)
+		ioat->domain = 0;
+	ioat->cpu = CPU_FFS(&cpuset_domain[ioat->domain]) - 1;
+	if (ioat->cpu < 0)
+		ioat->cpu = CPU_FIRST();
 
 	error = ioat_map_pci_bar(ioat);
 	if (error != 0)
@@ -523,8 +530,8 @@ ioat3_attach(device_t device)
 
 	ioat->hw_desc_ring = hw_desc;
 
-	ioat->ring = malloc(num_descriptors * sizeof(*ring), M_IOAT,
-	    M_ZERO | M_WAITOK);
+	ioat->ring = malloc_domainset(num_descriptors * sizeof(*ring), M_IOAT,
+	    DOMAINSET_PREF(ioat->domain), M_ZERO | M_WAITOK);
 
 	ring = ioat->ring;
 	for (i = 0; i < num_descriptors; i++) {
@@ -984,8 +991,8 @@ ioat_release(bus_dmaengine_t dmaengine)
 		    (uint16_t)ioat->head);
 
 		if (!callout_pending(&ioat->poll_timer)) {
-			callout_reset(&ioat->poll_timer, 1,
-			    ioat_poll_timer_callback, ioat);
+			callout_reset_on(&ioat->poll_timer, 1,
+			    ioat_poll_timer_callback, ioat, ioat->cpu);
 		}
 	}
 	mtx_unlock(&ioat->submit_lock);
@@ -1434,7 +1441,7 @@ ioat_free_ring(struct ioat_softc *ioat, uint32_t size,
     struct ioat_descriptor *ring)
 {
 
-	free(ring, M_IOAT);
+	free_domain(ring, M_IOAT);
 }
 
 static struct ioat_descriptor *

Modified: stable/12/sys/dev/ioat/ioat_internal.h
==============================================================================
--- stable/12/sys/dev/ioat/ioat_internal.h	Fri Sep 27 23:37:01 2019	(r352826)
+++ stable/12/sys/dev/ioat/ioat_internal.h	Sat Sep 28 00:59:39 2019	(r352827)
@@ -437,6 +437,8 @@ struct ioat_softc {
 })
 
 	device_t		device;
+	int			domain;
+	int			cpu;
 	int			version;
 	unsigned		chan_idx;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909280059.x8S0xdV8052904>