From patchwork Wed Aug 16 16:45:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9904147 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5E25E600CA for ; Wed, 16 Aug 2017 16:48:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4FB2928A1B for ; Wed, 16 Aug 2017 16:48:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44AF428A4C; Wed, 16 Aug 2017 16:48:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 852E728A1B for ; Wed, 16 Aug 2017 16:48:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1di1Rt-0001ze-F4; Wed, 16 Aug 2017 16:45:41 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1di1Rr-0001zI-Oh for xen-devel@lists.xenproject.org; Wed, 16 Aug 2017 16:45:39 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id CC/FD-01724-2B674995; Wed, 16 Aug 2017 16:45:38 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrHIsWRWlGSWpSXmKPExsVyMbThkO6msim RBq+aWS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyu5fsZCx6LVEx7mtLA2C7YxcjFISQwg1Hi 0qxX7CAOi8AaVomWbcdYQBwJgUusEjcafjJ1MXICOXESh3+eYoWwqyQWv50IZgsJqEjc3L6KC WLUT0aJU//XsYAkhAX0JI4c/QE0lgPIjpRY/tEcJMwmYCDxZsdesF4RASWJe6smg/UyC8xmkr gy8wZYL4uAqsT26f/ZQGxeAW+J3u4V7CA2p4CvxMIHl1kgFvtIHOzZywhiiwrISay83MIKUS8 ocXLmExaQvcwCmhLrd+mDhJkF5CW2v53DPIFRZBaSqlkIVbOQVC1gZF7FqFGcWlSWWqRraKGX VJSZnlGSm5iZo2toYKyXm1pcnJiempOYVKyXnJ+7iREY/vUMDIw7GH+f9jzEKMnBpCTK65U/J VKILyk/pTIjsTgjvqg0J7X4EKMMB4eSBK9MKVBOsCg1PbUiLTMHGIkwaQkOHiUR3rMgad7igs Tc4sx0iNQpRkuOK1fWfWHi2LB6PZCccmD7FyYhlrz8vFQpcd5FIA0CIA0ZpXlw42DJ4hKjrJQ wLyMDA4MQT0FqUW5mCar8K0ZxDkYlYV5ZkCk8mXklcFtfAR3EBHTQlfZJIAeVJCKkpBoY3S10 HOftvb2F/1NHxn+t5geR27yO7jJVWuTHIJgdcHn5wR2rcx2Vj/rd2Fr8uG/B5h3O1q4VT6a8n SE76/zE5le8/wTcf2xnetWv0Lu5J9N54sTpfPf2MPL128+dtWjx82NC9/0Ni4M3Ovz9sH61Wa pZuO023tbifxd+3jrQcKvp4MQM3rxrRUosxRmJhlrMRcWJAL/w9yoRAwAA X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1502901937!102697911!1 X-Originating-IP: [209.85.128.194] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 39859 invoked from network); 16 Aug 2017 16:45:38 -0000 Received: from mail-wr0-f194.google.com (HELO mail-wr0-f194.google.com) (209.85.128.194) by server-16.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 16 Aug 2017 16:45:38 -0000 Received: by mail-wr0-f194.google.com with SMTP id w63so4009052wrc.2 for ; Wed, 16 Aug 2017 09:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=1ish8extx06PHo4LZ9i1t0CFsevQ6klSrEp1wHXIlLo=; b=O7QWT2gYgZnb1uRbv/i2xKhIcGrr+13LS+UvsJblBXyaAbELX0UnCNuyU113UDEhlV Ea29ytApCvTN9AlngfI9+uTCxebhoZlMcIEbymqelWAsWlmL8Ga4veIrS3coD0Jf0cip jS3Th/0zXZeuMHYv57nCP5Whq77IHVT7Z2bhJnTCte72zaQ9UbGyu4uCtD3WVkUPtFbO Ke33q0xtiDRwM9Dc8JVZ28qQ2sDkQfOb9qlF/+JBYXIv12qEn60OR4npKhDMgqyEQPD7 seNDFberRxTjiM8w/usovxNbgRaK9e59UlhDu11VIkrAdfrm3CyxyP1zHTGC25Z5NJZY ylKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=1ish8extx06PHo4LZ9i1t0CFsevQ6klSrEp1wHXIlLo=; b=rp2rEpnHiJBDoEhaRBBI2geN9nZJn+U9jeA7SLUOBxutsH4U1CvkLPI55giB+fI9H5 sQ52ZUQKwIfnBBb1L/soFl5f/+bDR3HOe5JSdh3r1LAdSbFOa1RJIegHzQYjb+d8o9Yb Zzl8pSYTE89hJMLjdPrGLaggAtJP1ZyFhi99YrqlUUZDbQv6chaKza10pv5hULHCRjhs YiaHzl5tfwdxb1IteB7HTmCecoGqWdKtK8BVL8s+t/WielYbcRfOIcGoz1sp2bchK6tg +IBrmGnr60Bfu22fFgsdDUJjT9ENK+/SBU7hfogTXvYmU+uV8hE5DVPrr0wv3APaK4KU XJpw== X-Gm-Message-State: AHYfb5i1Paup5/9whJMh/mZlLBgyR69DsaIsDmndRI0mHtur8YgFoyRK MoLbGhLZna2rHA== X-Received: by 10.28.212.147 with SMTP id l141mr1688586wmg.13.1502901937669; Wed, 16 Aug 2017 09:45:37 -0700 (PDT) Received: from Solace.fritz.box ([80.66.223.3]) by smtp.gmail.com with ESMTPSA id a134sm1891257wma.47.2017.08.16.09.45.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 16 Aug 2017 09:45:36 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Wed, 16 Aug 2017 18:45:35 +0200 Message-ID: <150290193547.24854.2362617593969664852.stgit@Solace.fritz.box> In-Reply-To: <150290125292.24854.17418548557562763544.stgit@Solace.fritz.box> References: <150290125292.24854.17418548557562763544.stgit@Solace.fritz.box> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Cc: Stefano Stabellini , George Dunlap , Andrew Cooper , Tim Deegan , Julien Grall , Jan Beulich Subject: [Xen-devel] [PATCH v2 1/6] xen: in do_softirq() sample smp_processor_id() once and for all. X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In fact, right now, we read it at every iteration of the loop. The reason it's done like this is how context switch was handled on IA64 (see commit ae9bfcdc, "[XEN] Various softirq cleanups" [1]). However: 1) we don't have IA64 any longer, and all the achitectures that we do support, are ok with sampling once and for all; 2) sampling at every iteration (slightly) affect performance; 3) sampling at every iteration is misleading, as it makes people believe that it is currently possible that SCHEDULE_SOFTIRQ moves the execution flow on another CPU (and the comment, by reinforcing this belief, makes things even worse!). Therefore, let's: - do the sampling only once, and remove the comment; - leave an ASSERT() around, so that, if context switching logic changes (in current or new arches), we will notice. [1] Some more (historical) information here: http://old-list-archives.xenproject.org/archives/html/xen-devel/2006-06/msg01262.html Signed-off-by: Dario Faggioli Reviewed-by: George Dunlap --- Cc: Andrew Cooper Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Julien Grall Cc: Tim Deegan --- This has been submitted already, as a part of another series. Discussion is here: https://lists.xen.org/archives/html/xen-devel/2017-06/msg00102.html For the super lazy, Jan's latest word in that thread were these: "I've voiced my opinion, but I don't mean to block the patch. After all there's no active issue the change introduces." (https://lists.xen.org/archives/html/xen-devel/2017-06/msg00797.html) Since then: - changed "once and for all" with "only once", as requested by George (and applied his Reviewed-by, as he said I could). --- xen/common/softirq.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/xen/common/softirq.c b/xen/common/softirq.c index ac12cf8..67c84ba 100644 --- a/xen/common/softirq.c +++ b/xen/common/softirq.c @@ -27,16 +27,12 @@ static DEFINE_PER_CPU(unsigned int, batching); static void __do_softirq(unsigned long ignore_mask) { - unsigned int i, cpu; + unsigned int i, cpu = smp_processor_id(); unsigned long pending; for ( ; ; ) { - /* - * Initialise @cpu on every iteration: SCHEDULE_SOFTIRQ may move - * us to another processor. - */ - cpu = smp_processor_id(); + ASSERT(cpu == smp_processor_id()); if ( rcu_pending(cpu) ) rcu_check_callbacks(cpu);