Jia He says: ==================== Reduce cache miss for snmp_fold_field In a PowerPc server with large cpu number(160), besides commit a3a773726c9f ("net: Optimize snmp stat aggregation by walking all the percpu data at once"), I watched several other snmp_fold_field callsites which would cause high cache miss rate. test source code: ================ My simple test case, which read from the procfs items endlessly: /***********************************************************/ int main(int argc, char **argv) { int i; int fd = -1 ; int rdsize = 0; char buf[LINELEN+1]; buf[LINELEN] = 0; memset(buf,0,LINELEN); if(1 >= argc) { printf("file name empty\n"); return -1; } fd = open(argv[1], O_RDWR, 0644); if(0 > fd){ printf("open error\n"); return -2; } for(i=0;i<0xffffffff;i++) { while(0 < (rdsize = read(fd,buf,LINELEN))){ //nothing here } lseek(fd, 0, SEEK_SET); } close(fd); return 0; } /**********************************************************/ compile and run: ================ gcc test.c -o test perf stat -d -e cache-misses ./test /proc/net/snmp perf stat -d -e cache-misses ./test /proc/net/snmp6 perf stat -d -e cache-misses ./test /proc/net/sctp/snmp perf stat -d -e cache-misses ./test /proc/net/xfrm_stat before the patch set: ==================== Performance counter stats for 'system wide': 355911097 cache-misses [40.08%] 2356829300 L1-dcache-loads [60.04%] 355642645 L1-dcache-load-misses # 15.09% of all L1-dcache hits [60.02%] 346544541 LLC-loads [59.97%] 389763 LLC-load-misses # 0.11% of all LL-cache hits [40.02%] 6.245162638 seconds time elapsed After the patch set: =================== Performance counter stats for 'system wide': 194992476 cache-misses [40.03%] 6718051877 L1-dcache-loads [60.07%] 194871921 L1-dcache-load-misses # 2.90% of all L1-dcache hits [60.11%] 187632232 LLC-loads [60.04%] 464466 LLC-load-misses # 0.25% of all LL-cache hits [39.89%] 6.868422769 seconds time elapsed The cache-miss rate can be reduced from 15% to 2.9% changelog ========= v6: - correct v5 v5: - order local variables from longest to shortest line v4: - move memset into one block of if statement in snmp6_seq_show_item - remove the changes in netstat_seq_show considerred the stack usage is too large v3: - introduce generic interface (suggested by Marcelo Ricardo Leitner) - use max_t instead of self defined macro (suggested by David Miller) v2: - fix bug in udplite statistics. - snmp_seq_show is split into 2 parts ====================
Unified · Split
| @@ -219,6 +219,29 @@ static inline u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_o · 218 unmodified lines | |||
| 219 | } | 219 | } |
| 220 | #endif | 220 | #endif |
| 221 | 221 | ||
| 222 | #define snmp_get_cpu_field64_batch(buff64, stats_list, mib_statistic, offset) \ | ||
| 223 | { \ | ||
| 224 | int i, c; \ | ||
| 225 | for_each_possible_cpu(c) { \ | ||
| 226 | for (i = 0; stats_list[i].name; i++) \ | ||
| 227 | buff64[i] += snmp_get_cpu_field64( \ | ||
| 228 | mib_statistic, \ | ||
| 229 | c, stats_list[i].entry, \ | ||
| 230 | offset); \ | ||
| 231 | } \ | ||
| 232 | } | ||
| 233 | |||
| 234 | #define snmp_get_cpu_field_batch(buff, stats_list, mib_statistic) \ | ||
| 235 | { \ | ||
| 236 | int i, c; \ | ||
| 237 | for_each_possible_cpu(c) { \ | ||
| 238 | for (i = 0; stats_list[i].name; i++) \ | ||
| 239 | buff[i] += snmp_get_cpu_field( \ | ||
| 240 | mib_statistic, \ | ||
| 241 | c, stats_list[i].entry); \ | ||
| 242 | } \ | ||
| 243 | } | ||
| 244 | |||
| 222 | void inet_get_local_port_range(struct net *net, int *low, int *high); | 245 | void inet_get_local_port_range(struct net *net, int *low, int *high); |
| 223 | 246 | ||
| 224 | #ifdef CONFIG_SYSCTL | 247 | #ifdef CONFIG_SYSCTL |
| @@ -46,6 +46,8 @@ · 45 unmodified lines | |||
| 46 | #include <net/sock.h> | 46 | #include <net/sock.h> |
| 47 | #include <net/raw.h> | 47 | #include <net/raw.h> |
| 48 | 48 | ||
| 49 | #define TCPUDP_MIB_MAX max_t(u32, UDP_MIB_MAX, TCP_MIB_MAX) | ||
| 50 | |||
| 49 | /* | 51 | /* |
| 50 | * Report socket allocation statistics [mea@utu.fi] | 52 | * Report socket allocation statistics [mea@utu.fi] |
| 51 | */ | 53 | */ |
| @@ -356,22 +358,22 @@ static void icmp_put(struct seq_file *seq) · 304 unmodified lines | |||
| 356 | atomic_long_t *ptr = net->mib.icmpmsg_statistics->mibs; | 358 | atomic_long_t *ptr = net->mib.icmpmsg_statistics->mibs; |
| 357 | 359 | ||
| 358 | seq_puts(seq, "\nIcmp: InMsgs InErrors InCsumErrors"); | 360 | seq_puts(seq, "\nIcmp: InMsgs InErrors InCsumErrors"); |
| 359 | for (i = 0; icmpmibmap[i].name != NULL; i++) | 361 | for (i = 0; icmpmibmap[i].name; i++) |
| 360 | seq_printf(seq, " In%s", icmpmibmap[i].name); | 362 | seq_printf(seq, " In%s", icmpmibmap[i].name); |
| 361 | seq_puts(seq, " OutMsgs OutErrors"); | 363 | seq_puts(seq, " OutMsgs OutErrors"); |
| 362 | for (i = 0; icmpmibmap[i].name != NULL; i++) | 364 | for (i = 0; icmpmibmap[i].name; i++) |
| 363 | seq_printf(seq, " Out%s", icmpmibmap[i].name); | 365 | seq_printf(seq, " Out%s", icmpmibmap[i].name); |
| 364 | seq_printf(seq, "\nIcmp: %lu %lu %lu", | 366 | seq_printf(seq, "\nIcmp: %lu %lu %lu", |
| 365 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_INMSGS), | 367 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_INMSGS), |
| 366 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_INERRORS), | 368 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_INERRORS), |
| 367 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_CSUMERRORS)); | 369 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_CSUMERRORS)); |
| 368 | for (i = 0; icmpmibmap[i].name != NULL; i++) | 370 | for (i = 0; icmpmibmap[i].name; i++) |
| 369 | seq_printf(seq, " %lu", | 371 | seq_printf(seq, " %lu", |
| 370 | atomic_long_read(ptr + icmpmibmap[i].index)); | 372 | atomic_long_read(ptr + icmpmibmap[i].index)); |
| 371 | seq_printf(seq, " %lu %lu", | 373 | seq_printf(seq, " %lu %lu", |
| 372 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_OUTMSGS), | 374 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_OUTMSGS), |
| 373 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_OUTERRORS)); | 375 | snmp_fold_field(net->mib.icmp_statistics, ICMP_MIB_OUTERRORS)); |
| 374 | for (i = 0; icmpmibmap[i].name != NULL; i++) | 376 | for (i = 0; icmpmibmap[i].name; i++) |
| 375 | seq_printf(seq, " %lu", | 377 | seq_printf(seq, " %lu", |
| 376 | atomic_long_read(ptr + (icmpmibmap[i].index | 0x100))); | 378 | atomic_long_read(ptr + (icmpmibmap[i].index | 0x100))); |
| 377 | } | 379 | } |
| @@ -379,14 +381,16 @@ static void icmp_put(struct seq_file *seq) · 1 unmodified line | |||
| 379 | /* | 381 | /* |
| 380 | * Called from the PROCfs module. This outputs /proc/net/snmp. | 382 | * Called from the PROCfs module. This outputs /proc/net/snmp. |
| 381 | */ | 383 | */ |
| 382 | static int snmp_seq_show(struct seq_file *seq, void *v) | 384 | static int snmp_seq_show_ipstats(struct seq_file *seq, void *v) |
| 383 | { | 385 | { |
| 384 | int i; | ||
| 385 | struct net *net = seq->private; | 386 | struct net *net = seq->private; |
| 387 | u64 buff64[IPSTATS_MIB_MAX]; | ||
| 388 | int i; | ||
| 386 | 389 | ||
| 387 | seq_puts(seq, "Ip: Forwarding DefaultTTL"); | 390 | memset(buff64, 0, IPSTATS_MIB_MAX * sizeof(u64)); |
| 388 | 391 | ||
| 389 | for (i = 0; snmp4_ipstats_list[i].name != NULL; i++) | 392 | seq_puts(seq, "Ip: Forwarding DefaultTTL"); |
| 393 | for (i = 0; snmp4_ipstats_list[i].name; i++) | ||
| 390 | seq_printf(seq, " %s", snmp4_ipstats_list[i].name); | 394 | seq_printf(seq, " %s", snmp4_ipstats_list[i].name); |
| 391 | 395 | ||
| 392 | seq_printf(seq, "\nIp: %d %d", | 396 | seq_printf(seq, "\nIp: %d %d", |
| @@ -394,57 +398,77 @@ static int snmp_seq_show(struct seq_file *seq, void *v) · 1 unmodified line | |||
| 394 | net->ipv4.sysctl_ip_default_ttl); | 398 | net->ipv4.sysctl_ip_default_ttl); |
| 395 | 399 | ||
| 396 | BUILD_BUG_ON(offsetof(struct ipstats_mib, mibs) != 0); | 400 | BUILD_BUG_ON(offsetof(struct ipstats_mib, mibs) != 0); |
| 397 | for (i = 0; snmp4_ipstats_list[i].name != NULL; i++) | 401 | snmp_get_cpu_field64_batch(buff64, snmp4_ipstats_list, |
| 398 | seq_printf(seq, " %llu", | 402 | net->mib.ip_statistics, |
| 399 | snmp_fold_field64(net->mib.ip_statistics, | 403 | offsetof(struct ipstats_mib, syncp)); |
| 400 | snmp4_ipstats_list[i].entry, | 404 | for (i = 0; snmp4_ipstats_list[i].name; i++) |
| 401 | offsetof(struct ipstats_mib, syncp))); | 405 | seq_printf(seq, " %llu", buff64[i]); |
| 402 | 406 | ||
| 403 | icmp_put(seq); /* RFC 2011 compatibility */ | 407 | return 0; |
| 404 | icmpmsg_put(seq); | 408 | } |
| 409 | |||
| 410 | static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v) | ||
| 411 | { | ||
| 412 | unsigned long buff[TCPUDP_MIB_MAX]; | ||
| 413 | struct net *net = seq->private; | ||
| 414 | int i; | ||
| 415 | |||
| 416 | memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); | ||
| 405 | 417 | ||
| 406 | seq_puts(seq, "\nTcp:"); | 418 | seq_puts(seq, "\nTcp:"); |
| 407 | for (i = 0; snmp4_tcp_list[i].name != NULL; i++) | 419 | for (i = 0; snmp4_tcp_list[i].name; i++) |
| 408 | seq_printf(seq, " %s", snmp4_tcp_list[i].name); | 420 | seq_printf(seq, " %s", snmp4_tcp_list[i].name); |
| 409 | 421 | ||
| 410 | seq_puts(seq, "\nTcp:"); | 422 | seq_puts(seq, "\nTcp:"); |
| 411 | for (i = 0; snmp4_tcp_list[i].name != NULL; i++) { | 423 | snmp_get_cpu_field_batch(buff, snmp4_tcp_list, |
| 424 | net->mib.tcp_statistics); | ||
| 425 | for (i = 0; snmp4_tcp_list[i].name; i++) { | ||
| 412 | /* MaxConn field is signed, RFC 2012 */ | 426 | /* MaxConn field is signed, RFC 2012 */ |
| 413 | if (snmp4_tcp_list[i].entry == TCP_MIB_MAXCONN) | 427 | if (snmp4_tcp_list[i].entry == TCP_MIB_MAXCONN) |
| 414 | seq_printf(seq, " %ld", | 428 | seq_printf(seq, " %ld", buff[i]); |
| 415 | snmp_fold_field(net->mib.tcp_statistics, | ||
| 416 | snmp4_tcp_list[i].entry)); | ||
| 417 | else | 429 | else |
| 418 | seq_printf(seq, " %lu", | 430 | seq_printf(seq, " %lu", buff[i]); |
| 419 | snmp_fold_field(net->mib.tcp_statistics, | ||
| 420 | snmp4_tcp_list[i].entry)); | ||
| 421 | } | 431 | } |
| 422 | 432 | ||
| 433 | memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); | ||
| 434 | |||
| 435 | snmp_get_cpu_field_batch(buff, snmp4_udp_list, | ||
| 436 | net->mib.udp_statistics); | ||
| 423 | seq_puts(seq, "\nUdp:"); | 437 | seq_puts(seq, "\nUdp:"); |
| 424 | for (i = 0; snmp4_udp_list[i].name != NULL; i++) | 438 | for (i = 0; snmp4_udp_list[i].name; i++) |
| 425 | seq_printf(seq, " %s", snmp4_udp_list[i].name); | 439 | seq_printf(seq, " %s", snmp4_udp_list[i].name); |
| 426 | |||
| 427 | seq_puts(seq, "\nUdp:"); | 440 | seq_puts(seq, "\nUdp:"); |
| 428 | for (i = 0; snmp4_udp_list[i].name != NULL; i++) | 441 | for (i = 0; snmp4_udp_list[i].name; i++) |
| 429 | seq_printf(seq, " %lu", | 442 | seq_printf(seq, " %lu", buff[i]); |
| 430 | snmp_fold_field(net->mib.udp_statistics, | 443 | |
| 431 | snmp4_udp_list[i].entry)); | 444 | memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); |
| 432 | 445 | ||
| 433 | /* the UDP and UDP-Lite MIBs are the same */ | 446 | /* the UDP and UDP-Lite MIBs are the same */ |
| 434 | seq_puts(seq, "\nUdpLite:"); | 447 | seq_puts(seq, "\nUdpLite:"); |
| 435 | for (i = 0; snmp4_udp_list[i].name != NULL; i++) | 448 | snmp_get_cpu_field_batch(buff, snmp4_udp_list, |
| 449 | net->mib.udplite_statistics); | ||
| 450 | for (i = 0; snmp4_udp_list[i].name; i++) | ||
| 436 | seq_printf(seq, " %s", snmp4_udp_list[i].name); | 451 | seq_printf(seq, " %s", snmp4_udp_list[i].name); |
| 437 | |||
| 438 | seq_puts(seq, "\nUdpLite:"); | 452 | seq_puts(seq, "\nUdpLite:"); |
| 439 | for (i = 0; snmp4_udp_list[i].name != NULL; i++) | 453 | for (i = 0; snmp4_udp_list[i].name; i++) |
| 440 | seq_printf(seq, " %lu", | 454 | seq_printf(seq, " %lu", buff[i]); |
| 441 | snmp_fold_field(net->mib.udplite_statistics, | ||
| 442 | snmp4_udp_list[i].entry)); | ||
| 443 | 455 | ||
| 444 | seq_putc(seq, '\n'); | 456 | seq_putc(seq, '\n'); |
| 445 | return 0; | 457 | return 0; |
| 446 | } | 458 | } |
| 447 | 459 | ||
| 460 | static int snmp_seq_show(struct seq_file *seq, void *v) | ||
| 461 | { | ||
| 462 | snmp_seq_show_ipstats(seq, v); | ||
| 463 | |||
| 464 | icmp_put(seq); /* RFC 2011 compatibility */ | ||
| 465 | icmpmsg_put(seq); | ||
| 466 | |||
| 467 | snmp_seq_show_tcp_udp(seq, v); | ||
| 468 | |||
| 469 | return 0; | ||
| 470 | } | ||
| 471 | |||
| 448 | static int snmp_seq_open(struct inode *inode, struct file *file) | 472 | static int snmp_seq_open(struct inode *inode, struct file *file) |
| 449 | { | 473 | { |
| 450 | return single_open_net(inode, file, snmp_seq_show); | 474 | return single_open_net(inode, file, snmp_seq_show); |
| @@ -469,21 +493,21 @@ static int netstat_seq_show(struct seq_file *seq, void *v) · 18 unmodified lines | |||
| 469 | struct net *net = seq->private; | 493 | struct net *net = seq->private; |
| 470 | 494 | ||
| 471 | seq_puts(seq, "TcpExt:"); | 495 | seq_puts(seq, "TcpExt:"); |
| 472 | for (i = 0; snmp4_net_list[i].name != NULL; i++) | 496 | for (i = 0; snmp4_net_list[i].name; i++) |
| 473 | seq_printf(seq, " %s", snmp4_net_list[i].name); | 497 | seq_printf(seq, " %s", snmp4_net_list[i].name); |
| 474 | 498 | ||
| 475 | seq_puts(seq, "\nTcpExt:"); | 499 | seq_puts(seq, "\nTcpExt:"); |
| 476 | for (i = 0; snmp4_net_list[i].name != NULL; i++) | 500 | for (i = 0; snmp4_net_list[i].name; i++) |
| 477 | seq_printf(seq, " %lu", | 501 | seq_printf(seq, " %lu", |
| 478 | snmp_fold_field(net->mib.net_statistics, | 502 | snmp_fold_field(net->mib.net_statistics, |
| 479 | snmp4_net_list[i].entry)); | 503 | snmp4_net_list[i].entry)); |
| 480 | 504 | ||
| 481 | seq_puts(seq, "\nIpExt:"); | 505 | seq_puts(seq, "\nIpExt:"); |
| 482 | for (i = 0; snmp4_ipextstats_list[i].name != NULL; i++) | 506 | for (i = 0; snmp4_ipextstats_list[i].name; i++) |
| 483 | seq_printf(seq, " %s", snmp4_ipextstats_list[i].name); | 507 | seq_printf(seq, " %s", snmp4_ipextstats_list[i].name); |
| 484 | 508 | ||
| 485 | seq_puts(seq, "\nIpExt:"); | 509 | seq_puts(seq, "\nIpExt:"); |
| 486 | for (i = 0; snmp4_ipextstats_list[i].name != NULL; i++) | 510 | for (i = 0; snmp4_ipextstats_list[i].name; i++) |
| 487 | seq_printf(seq, " %llu", | 511 | seq_printf(seq, " %llu", |
| 488 | snmp_fold_field64(net->mib.ip_statistics, | 512 | snmp_fold_field64(net->mib.ip_statistics, |
| 489 | snmp4_ipextstats_list[i].entry, | 513 | snmp4_ipextstats_list[i].entry, |
| @@ -4961,18 +4961,18 @@ static inline size_t inet6_if_nlmsg_size(void) · 4960 unmodified lines | |||
| 4961 | } | 4961 | } |
| 4962 | 4962 | ||
| 4963 | static inline void __snmp6_fill_statsdev(u64 *stats, atomic_long_t *mib, | 4963 | static inline void __snmp6_fill_statsdev(u64 *stats, atomic_long_t *mib, |
| 4964 | int items, int bytes) | 4964 | int bytes) |
| 4965 | { | 4965 | { |
| 4966 | int i; | 4966 | int i; |
| 4967 | int pad = bytes - sizeof(u64) * items; | 4967 | int pad = bytes - sizeof(u64) * ICMP6_MIB_MAX; |
| 4968 | BUG_ON(pad < 0); | 4968 | BUG_ON(pad < 0); |
| 4969 | 4969 | ||
| 4970 | /* Use put_unaligned() because stats may not be aligned for u64. */ | 4970 | /* Use put_unaligned() because stats may not be aligned for u64. */ |
| 4971 | put_unaligned(items, &stats[0]); | 4971 | put_unaligned(ICMP6_MIB_MAX, &stats[0]); |
| 4972 | for (i = 1; i < items; i++) | 4972 | for (i = 1; i < ICMP6_MIB_MAX; i++) |
| 4973 | put_unaligned(atomic_long_read(&mib[i]), &stats[i]); | 4973 | put_unaligned(atomic_long_read(&mib[i]), &stats[i]); |
| 4974 | 4974 | ||
| 4975 | memset(&stats[items], 0, pad); | 4975 | memset(&stats[ICMP6_MIB_MAX], 0, pad); |
| 4976 | } | 4976 | } |
| 4977 | 4977 | ||
| 4978 | static inline void __snmp6_fill_stats64(u64 *stats, void __percpu *mib, | 4978 | static inline void __snmp6_fill_stats64(u64 *stats, void __percpu *mib, |
| @@ -5005,7 +5005,7 @@ static void snmp6_fill_stats(u64 *stats, struct inet6_dev *idev, int attrtype, · 26 unmodified lines | |||
| 5005 | offsetof(struct ipstats_mib, syncp)); | 5005 | offsetof(struct ipstats_mib, syncp)); |
| 5006 | break; | 5006 | break; |
| 5007 | case IFLA_INET6_ICMP6STATS: | 5007 | case IFLA_INET6_ICMP6STATS: |
| 5008 | __snmp6_fill_statsdev(stats, idev->stats.icmpv6dev->mibs, ICMP6_MIB_MAX, bytes); | 5008 | __snmp6_fill_statsdev(stats, idev->stats.icmpv6dev->mibs, bytes); |
| 5009 | break; | 5009 | break; |
| 5010 | } | 5010 | } |
| 5011 | } | 5011 | } |
| @@ -30,6 +30,11 @@ · 29 unmodified lines | |||
| 30 | #include <net/transp_v6.h> | 30 | #include <net/transp_v6.h> |
| 31 | #include <net/ipv6.h> | 31 | #include <net/ipv6.h> |
| 32 | 32 | ||
| 33 | #define MAX4(a, b, c, d) \ | ||
| 34 | max_t(u32, max_t(u32, a, b), max_t(u32, c, d)) | ||
| 35 | #define SNMP_MIB_MAX MAX4(UDP_MIB_MAX, TCP_MIB_MAX, \ | ||
| 36 | IPSTATS_MIB_MAX, ICMP_MIB_MAX) | ||
| 37 | |||
| 33 | static int sockstat6_seq_show(struct seq_file *seq, void *v) | 38 | static int sockstat6_seq_show(struct seq_file *seq, void *v) |
| 34 | { | 39 | { |
| 35 | struct net *net = seq->private; | 40 | struct net *net = seq->private; |
| @@ -191,25 +196,34 @@ static void snmp6_seq_show_item(struct seq_file *seq, void __percpu *pcpumib, · 155 unmodified lines | |||
| 191 | atomic_long_t *smib, | 196 | atomic_long_t *smib, |
| 192 | const struct snmp_mib *itemlist) | 197 | const struct snmp_mib *itemlist) |
| 193 | { | 198 | { |
| 199 | unsigned long buff[SNMP_MIB_MAX]; | ||
| 194 | int i; | 200 | int i; |
| 195 | unsigned long val; | ||
| 196 | 201 | ||
| 197 | for (i = 0; itemlist[i].name; i++) { | 202 | if (pcpumib) { |
| 198 | val = pcpumib ? | 203 | memset(buff, 0, sizeof(unsigned long) * SNMP_MIB_MAX); |
| 199 | snmp_fold_field(pcpumib, itemlist[i].entry) : | 204 | |
| 200 | atomic_long_read(smib + itemlist[i].entry); | 205 | snmp_get_cpu_field_batch(buff, itemlist, pcpumib); |
| 201 | seq_printf(seq, "%-32s\t%lu\n", itemlist[i].name, val); | 206 | for (i = 0; itemlist[i].name; i++) |
| 207 | seq_printf(seq, "%-32s\t%lu\n", | ||
| 208 | itemlist[i].name, buff[i]); | ||
| 209 | } else { | ||
| 210 | for (i = 0; itemlist[i].name; i++) | ||
| 211 | seq_printf(seq, "%-32s\t%lu\n", itemlist[i].name, | ||
| 212 | atomic_long_read(smib + itemlist[i].entry)); | ||
| 202 | } | 213 | } |
| 203 | } | 214 | } |
| 204 | 215 | ||
| 205 | static void snmp6_seq_show_item64(struct seq_file *seq, void __percpu *mib, | 216 | static void snmp6_seq_show_item64(struct seq_file *seq, void __percpu *mib, |
| 206 | const struct snmp_mib *itemlist, size_t syncpoff) | 217 | const struct snmp_mib *itemlist, size_t syncpoff) |
| 207 | { | 218 | { |
| 219 | u64 buff64[SNMP_MIB_MAX]; | ||
| 208 | int i; | 220 | int i; |
| 209 | 221 | ||
| 222 | memset(buff64, 0, sizeof(unsigned long) * SNMP_MIB_MAX); | ||
| 223 | |||
| 224 | snmp_get_cpu_field64_batch(buff64, itemlist, mib, syncpoff); | ||
| 210 | for (i = 0; itemlist[i].name; i++) | 225 | for (i = 0; itemlist[i].name; i++) |
| 211 | seq_printf(seq, "%-32s\t%llu\n", itemlist[i].name, | 226 | seq_printf(seq, "%-32s\t%llu\n", itemlist[i].name, buff64[i]); |
| 212 | snmp_fold_field64(mib, itemlist[i].entry, syncpoff)); | ||
| 213 | } | 227 | } |
| 214 | 228 | ||
| 215 | static int snmp6_seq_show(struct seq_file *seq, void *v) | 229 | static int snmp6_seq_show(struct seq_file *seq, void *v) |
| @@ -73,13 +73,17 @@ static const struct snmp_mib sctp_snmp_list[] = { · 72 unmodified lines | |||
| 73 | /* Display sctp snmp mib statistics(/proc/net/sctp/snmp). */ | 73 | /* Display sctp snmp mib statistics(/proc/net/sctp/snmp). */ |
| 74 | static int sctp_snmp_seq_show(struct seq_file *seq, void *v) | 74 | static int sctp_snmp_seq_show(struct seq_file *seq, void *v) |
| 75 | { | 75 | { |
| 76 | unsigned long buff[SCTP_MIB_MAX]; | ||
| 76 | struct net *net = seq->private; | 77 | struct net *net = seq->private; |
| 77 | int i; | 78 | int i; |
| 78 | 79 | ||
| 79 | for (i = 0; sctp_snmp_list[i].name != NULL; i++) | 80 | memset(buff, 0, sizeof(unsigned long) * SCTP_MIB_MAX); |
| 81 | |||
| 82 | snmp_get_cpu_field_batch(buff, sctp_snmp_list, | ||
| 83 | net->sctp.sctp_statistics); | ||
| 84 | for (i = 0; sctp_snmp_list[i].name; i++) | ||
| 80 | seq_printf(seq, "%-32s\t%ld\n", sctp_snmp_list[i].name, | 85 | seq_printf(seq, "%-32s\t%ld\n", sctp_snmp_list[i].name, |
| 81 | snmp_fold_field(net->sctp.sctp_statistics, | 86 | buff[i]); |
| 82 | sctp_snmp_list[i].entry)); | ||
| 83 | 87 | ||
| 84 | return 0; | 88 | return 0; |
| 85 | } | 89 | } |
| @@ -50,12 +50,18 @@ static const struct snmp_mib xfrm_mib_list[] = { · 49 unmodified lines | |||
| 50 | 50 | ||
| 51 | static int xfrm_statistics_seq_show(struct seq_file *seq, void *v) | 51 | static int xfrm_statistics_seq_show(struct seq_file *seq, void *v) |
| 52 | { | 52 | { |
| 53 | unsigned long buff[LINUX_MIB_XFRMMAX]; | ||
| 53 | struct net *net = seq->private; | 54 | struct net *net = seq->private; |
| 54 | int i; | 55 | int i; |
| 56 | |||
| 57 | memset(buff, 0, sizeof(unsigned long) * LINUX_MIB_XFRMMAX); | ||
| 58 | |||
| 59 | snmp_get_cpu_field_batch(buff, xfrm_mib_list, | ||
| 60 | net->mib.xfrm_statistics); | ||
| 55 | for (i = 0; xfrm_mib_list[i].name; i++) | 61 | for (i = 0; xfrm_mib_list[i].name; i++) |
| 56 | seq_printf(seq, "%-24s\t%lu\n", xfrm_mib_list[i].name, | 62 | seq_printf(seq, "%-24s\t%lu\n", xfrm_mib_list[i].name, |
| 57 | snmp_fold_field(net->mib.xfrm_statistics, | 63 | buff[i]); |
| 58 | xfrm_mib_list[i].entry)); | 64 | |
| 59 | return 0; | 65 | return 0; |
| 60 | } | 66 | } |
| 61 | 67 | ||