Message ID | 1264773952.3184.22.camel@edumazet-laptop |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
Hi Eric, On Fri, Jan 29, 2010 at 03:05:52PM +0100, Eric Dumazet wrote: > Use atomic_inc_return() in get_acqseq() to avoid taking a spinlock > + static atomic_t acqseq; I think that needs to be: static atomic_t acqseq = ATOMIC_INIT(0); Cheers, -ben -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Le vendredi 29 janvier 2010 à 10:11 -0500, Benjamin LaHaise a écrit : > Hi Eric, > > On Fri, Jan 29, 2010 at 03:05:52PM +0100, Eric Dumazet wrote: > > Use atomic_inc_return() in get_acqseq() to avoid taking a spinlock > > + static atomic_t acqseq; > > I think that needs to be: > static atomic_t acqseq = ATOMIC_INIT(0); > > Cheers, > > -ben Not sure its needed now that atomic_t is an integral 32bits type for all arches, or a cleanup patch is wanted :) Thanks ! ./security/tomoyo/realpath.c:412:static atomic_t tomoyo_dynamic_memory_size; ./arch/sh/kernel/perf_event.c:41:static atomic_t num_events; ./arch/um/kernel/smp.c:199:static atomic_t scf_started; ./arch/um/kernel/smp.c:200:static atomic_t scf_finished; ./arch/ia64/kernel/mca.c:1287: static atomic_t mca_count; ./arch/ia64/kernel/mca.c:1661: static atomic_t slaves; ./arch/ia64/kernel/mca.c:1662: static atomic_t monarchs; ./arch/ia64/kernel/crash.c:24:static atomic_t kdump_cpu_frozen; ./arch/x86/mm/mmio-mod.c:62:static atomic_t mmiotrace_enabled; ./arch/x86/mm/mmio-mod.c:237: static atomic_t next_id; ./arch/x86/kernel/cpu/perf_event.c:714:static atomic_t active_events; ./arch/x86/kernel/cpu/mcheck/mce.c:238:static atomic_t mce_paniced; ./arch/x86/kernel/cpu/mcheck/mce.c:241:static atomic_t mce_fake_paniced; ./arch/x86/kernel/cpu/mcheck/mce.c:614:static atomic_t mce_executing; ./arch/x86/kernel/cpu/mcheck/mce.c:619:static atomic_t mce_callin; ./arch/x86/kernel/cpu/mcheck/mce.c:727:static atomic_t global_nwo; ./arch/x86/kernel/tboot.c:297:static atomic_t ap_wfs_count; ./arch/x86/kernel/reboot.c:724:static atomic_t waiting_for_crash_ipi; ./arch/blackfin/kernel/irqchip.c:17:static atomic_t irq_err_count; ./arch/microblaze/kernel/of_device.c:14: static atomic_t bus_no_reg_magic; ./arch/powerpc/platforms/iseries/viopath.c:74:static atomic_t event_buffer_available[VIO_MAX_SUBTYPES]; ./arch/powerpc/kernel/of_device.c:15: static atomic_t bus_no_reg_magic; ./arch/powerpc/kernel/perf_event.c:959:static atomic_t num_events; ./mm/memcontrol.c:1283:static atomic_t memcg_drain_count; ./virt/kvm/kvm_main.c:75:static atomic_t hardware_enable_failed; ./net/netfilter/nfnetlink_log.c:71:static atomic_t global_seq; ./net/decnet/af_decnet.c:158:static atomic_t decnet_memory_allocated; ./net/llc/llc_conn.c:775:static atomic_t llc_sock_nr; ./net/core/netpoll.c:41:static atomic_t trapped; ./net/sctp/socket.c:116:static atomic_t sctp_memory_allocated; ./net/sunrpc/sched.c:238: static atomic_t rpc_pid; ./fs/ocfs2/stack_user.c:160:static atomic_t ocfs2_control_opened; ./fs/notify/inotify/inotify.c:37:static atomic_t inotify_cookie; ./fs/notify/inotify/inotify_user.c:62:static atomic_t inotify_grp_num; ./fs/afs/rxrpc.c:20:static atomic_t afs_outstanding_calls; ./fs/afs/rxrpc.c:21:static atomic_t afs_outstanding_skbs; ./fs/afs/super.c:59:static atomic_t afs_count_active_inodes; ./fs/quota/quota.c:558: static atomic_t seq; ./fs/dlm/user.c:29:static atomic_t dlm_monitor_opened; ./fs/ecryptfs/miscdev.c:31:static atomic_t ecryptfs_num_miscdev_opens; ./kernel/rcutree.c:1575:static atomic_t rcu_barrier_cpu_count; ./kernel/trace/trace.c:807:static atomic_t trace_record_cmdline_disabled __read_mostly; ./kernel/trace/trace_mmiotrace.c:26:static atomic_t dropped_count; ./kernel/slow-work.c:85:static atomic_t slow_work_thread_count; ./kernel/slow-work.c:86:static atomic_t vslow_work_executing_count; ./kernel/rtmutex-tester.c:24:static atomic_t rttest_event; ./kernel/async.c:83:static atomic_t entry_count; ./kernel/async.c:84:static atomic_t thread_count; ./kernel/perf_event.c:45:static atomic_t nr_events __read_mostly; ./kernel/perf_event.c:46:static atomic_t nr_mmap_events __read_mostly; ./kernel/perf_event.c:47:static atomic_t nr_comm_events __read_mostly; ./kernel/perf_event.c:48:static atomic_t nr_task_events __read_mostly; ./kernel/profile.c:42:static atomic_t *prof_buffer; ./kernel/rcutorture.c:121:static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1]; ./kernel/rcutorture.c:122:static atomic_t n_rcu_torture_alloc; ./kernel/rcutorture.c:123:static atomic_t n_rcu_torture_alloc_fail; ./kernel/rcutorture.c:124:static atomic_t n_rcu_torture_free; ./kernel/rcutorture.c:125:static atomic_t n_rcu_torture_mberror; ./kernel/rcutorture.c:126:static atomic_t n_rcu_torture_error; ./kernel/stop_machine.c:39:static atomic_t thread_ack; ./kernel/kgdb.c:124:static atomic_t passive_cpu_wait[NR_CPUS]; ./kernel/kgdb.c:125:static atomic_t cpu_in_kgdb[NR_CPUS]; ./kernel/time/timer_stats.c:119:static atomic_t overflow_count; ./drivers/dma/ppc4xx/adma.c:106:static atomic_t ppc440spe_adma_err_irq_ref; ./drivers/s390/cio/css.c:470:static atomic_t css_eval_scheduled; ./drivers/s390/cio/cio.c:960:static atomic_t chpid_reset_count; ./drivers/pci/hotplug/cpci_hotplug_core.c:59:static atomic_t extracting; ./drivers/char/rocket.c:114:static atomic_t rp_num_ports_open; /* Number of serial ports open */ ./drivers/char/ipmi/ipmi_msghandler.c:4044:static atomic_t stop_operation; ./drivers/md/md.c:160:static atomic_t md_event_count; ./drivers/ieee1394/raw1394.c:79:static atomic_t iso_buffer_size; ./drivers/usb/serial/io_edgeport.c:196:static atomic_t CmdUrbs; /* Number of outstanding Command Write Urbs */ ./drivers/net/pppol2tp.c:229:static atomic_t pppol2tp_tunnel_count; ./drivers/net/pppol2tp.c:230:static atomic_t pppol2tp_session_count; ./drivers/net/vmxnet3/vmxnet3_drv.c:45:static atomic_t devices_found; ./drivers/watchdog/bcm47xx_wdt.c:52:static atomic_t ticks; ./drivers/staging/batman-adv/routing.c:46:static atomic_t data_ready_cond; ./drivers/scsi/lpfc/lpfc_debugfs.c:1214:static atomic_t lpfc_debugfs_hba_count; ./drivers/scsi/scsi_transport_fc.c:484:static atomic_t fc_event_seq; ./drivers/scsi/hosts.c:43:static atomic_t scsi_host_next_hn; /* host_no for next new host */ ./drivers/scsi/scsi_transport_iscsi.c:84:static atomic_t iscsi_session_nr; /* sysfs session id for next new session */ ./drivers/scsi/qla2xxx/qla_dfs.c:13:static atomic_t qla2x00_dfs_root_count; ./drivers/crypto/hifn_795x.c:54:static atomic_t hifn_dev_number; -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Fri, Jan 29, 2010 at 05:00:19PM +0100, Eric Dumazet wrote: > Not sure its needed now that atomic_t is an integral 32bits type for all > arches, or a cleanup patch is wanted :) > > Thanks ! Ah, yes, it looks like things have changed in this area a bit over time. I'll do up a cleanup patch for this. -ben -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Eric Dumazet <eric.dumazet@gmail.com> Date: Fri, 29 Jan 2010 15:05:52 +0100 > Use atomic_inc_return() in get_acqseq() to avoid taking a spinlock > > Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Applied. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/key/af_key.c b/net/key/af_key.c index 4744b1f..e2aacf0 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c @@ -3019,12 +3019,11 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, struct km_e static u32 get_acqseq(void) { u32 res; - static u32 acqseq; - static DEFINE_SPINLOCK(acqseq_lock); + static atomic_t acqseq; - spin_lock_bh(&acqseq_lock); - res = (++acqseq ? : ++acqseq); - spin_unlock_bh(&acqseq_lock); + do { + res = atomic_inc_return(&acqseq); + } while (!res); return res; }
Use atomic_inc_return() in get_acqseq() to avoid taking a spinlock Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> --- -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html