Commit 3291b9db authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

pktgen: NUMA aware

pktgen threads are bound to given CPU, we can allocate memory for
these threads in a NUMA aware way.

After a pktgen session on two threads, we can check flows memory was
allocated on right node, instead of a not related one.

# grep pktgen_thread_write /proc/vmallocinfo
0xffffc90007204000-0xffffc90007385000 1576960 pktgen_thread_write+0x3a4/0x6b0 [pktgen] pages=384 vmalloc N0=384
0xffffc90007386000-0xffffc90007507000 1576960 pktgen_thread_write+0x3a4/0x6b0 [pktgen] pages=384 vmalloc N1=384
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9b963e5d
...@@ -3626,6 +3626,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname) ...@@ -3626,6 +3626,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
{ {
struct pktgen_dev *pkt_dev; struct pktgen_dev *pkt_dev;
int err; int err;
int node = cpu_to_node(t->cpu);
/* We don't allow a device to be on several threads */ /* We don't allow a device to be on several threads */
...@@ -3635,12 +3636,13 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname) ...@@ -3635,12 +3636,13 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
return -EBUSY; return -EBUSY;
} }
pkt_dev = kzalloc(sizeof(struct pktgen_dev), GFP_KERNEL); pkt_dev = kzalloc_node(sizeof(struct pktgen_dev), GFP_KERNEL, node);
if (!pkt_dev) if (!pkt_dev)
return -ENOMEM; return -ENOMEM;
strcpy(pkt_dev->odevname, ifname); strcpy(pkt_dev->odevname, ifname);
pkt_dev->flows = vmalloc(MAX_CFLOWS * sizeof(struct flow_state)); pkt_dev->flows = vmalloc_node(MAX_CFLOWS * sizeof(struct flow_state),
node);
if (pkt_dev->flows == NULL) { if (pkt_dev->flows == NULL) {
kfree(pkt_dev); kfree(pkt_dev);
return -ENOMEM; return -ENOMEM;
...@@ -3702,7 +3704,8 @@ static int __init pktgen_create_thread(int cpu) ...@@ -3702,7 +3704,8 @@ static int __init pktgen_create_thread(int cpu)
struct proc_dir_entry *pe; struct proc_dir_entry *pe;
struct task_struct *p; struct task_struct *p;
t = kzalloc(sizeof(struct pktgen_thread), GFP_KERNEL); t = kzalloc_node(sizeof(struct pktgen_thread), GFP_KERNEL,
cpu_to_node(cpu));
if (!t) { if (!t) {
printk(KERN_ERR "pktgen: ERROR: out of memory, can't " printk(KERN_ERR "pktgen: ERROR: out of memory, can't "
"create new thread.\n"); "create new thread.\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment