Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761093Ab2KAMQm (ORCPT ); Thu, 1 Nov 2012 08:16:42 -0400 Received: from mx0.aculab.com ([213.249.233.131]:53652 "HELO mx0.aculab.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1756264Ab2KAMQj (ORCPT ); Thu, 1 Nov 2012 08:16:39 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Subject: RE: [PATCH 3/9] net: xfrm: use this_cpu_ptr per-cpu helper Date: Thu, 1 Nov 2012 12:15:50 -0000 Message-ID: In-Reply-To: <50923956.5090206@gmail.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: thread-topic: [PATCH 3/9] net: xfrm: use this_cpu_ptr per-cpu helper thread-index: Ac24DvJGr57KwqY8QU2JzE4svQI8SgAGrdWw References: <509109F9.3030904@gmail.com> <0000013ab7e4a640-60bd5b38-a1fc-4730-b918-4109211ffea0-000000@email.amazonses.com> <50923956.5090206@gmail.com> From: "David Laight" To: "Shan Wei" , "Christoph Lameter" Cc: , "David Miller" , "NetDev" , "Herbert Xu" , "Kernel-Maillist" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id qA1CGkv3024535 Content-Length: 1435 Lines: 32 > this_cpu_read > |-----_this_cpu_generic_read > > #define _this_cpu_generic_read(pcp) \ > ({ typeof(pcp) ret__; \ > preempt_disable(); \ > ret__ = *this_cpu_ptr(&(pcp)); \ > preempt_enable(); \ > ret__; \ > }) > > > this_cpu_read operations locate per-cpu variable with preemption safe, not > disable interrupts. why is it atomic vs interrupts? Hmmm... what effect do those preemt_dis/enable() actually have? Since a pre-empt can happen either side of them, the value the caller sees can be for the wrong cpu anyway. The only time I could see them being necessary is if *this_cpu_ptr() itself needs mutex protection in order to function correctly - and that is likely to be port specific. On i386/amd64 where (I guess) it is an access offset by fs/gs this isn't necessary and just wastes cpu cycles. If the caller cares which cpu the value comes from (eg to increment a counter) then the caller would need to disable pre-emption across the whole operation. David ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?