From patchwork Thu Jun 1 17:33:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9760711 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 DDBE260363 for ; Thu, 1 Jun 2017 17:36:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9C6927569 for ; Thu, 1 Jun 2017 17:36:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE9BC28518; Thu, 1 Jun 2017 17:36:21 +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 40FD527569 for ; Thu, 1 Jun 2017 17:36:21 +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 1dGTyk-0008L2-PW; Thu, 01 Jun 2017 17:33:46 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dGTyj-0008Kq-9u for xen-devel@lists.xenproject.org; Thu, 01 Jun 2017 17:33:45 +0000 Received: from [85.158.143.35] by server-10.bemta-6.messagelabs.com id F9/34-03613-8FF40395; Thu, 01 Jun 2017 17:33:44 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJIsWRWlGSWpSXmKPExsXiVRvkqPvd3yD SYM93S4vvWyYzOTB6HP5whSWAMYo1My8pvyKBNePtPMOCXQIVd09fZ21gXM/bxcjFISQwg1Hi 160ljCAOi8AaVok/d/uZQRwJgUusElNfLmLtYuQEcuIktjWfYoOwKyQeb/3FDGILCahI3Ny+i gli1E9Gib13FzGBJIQF9CSOHP3BDmFHSPx5exysgU3AQOLNjr1gQ0UElCTurZoM1swsMJtJom PdDbAEi4CqxNqHDxhBbF4BT4lJ2w+ANXMK+EpMOnWGEWKzj8S3XxPAlokKyEmsvNzCClEvKHF y5hOWLkYOoKGaEut36YOEmQXkJba/ncM8gVFkFpKqWQhVs5BULWBkXsWoUZxaVJZapGtspJdU lJmeUZKbmJmja2hgppebWlycmJ6ak5hUrJecn7uJERgBDECwg/H0usBDjJIcTEqivAvkDSKF+ JLyUyozEosz4otKc1KLDzHKcHAoSfBe8APKCRalpqdWpGXmAGMRJi3BwaMkwpsCkuYtLkjMLc 5Mh0idYjTm2LB6/RcmjkkHtn9hEmLJy89LlRLnXQpSKgBSmlGaBzcIliIuMcpKCfMyAp0mxFO QWpSbWYIq/4pRnINRSZh3JcgUnsy8Erh9r4BOYQI65cU2fZBTShIRUlINjKvyg1r9nzzxufDz durOsBNn7kcGZTRcyT+3SOmG0KlTVg/O9hmGMXMdOLmuU/rYjwUWB2vSNX4vnnr664w+qaxD7 JoHv8x+fDls790IDemJkatbsyZt3fLPdcplzXAz6/OOFslvXe5K7lXZpFJ2PLVBJ0Rd4btsQR E7ezDzfKnE6iOzGZXFDyqxFGckGmoxFxUnAgBiJcAcDAMAAA== X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-2.tower-21.messagelabs.com!1496338423!57939597!1 X-Originating-IP: [74.125.82.65] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31599 invoked from network); 1 Jun 2017 17:33:43 -0000 Received: from mail-wm0-f65.google.com (HELO mail-wm0-f65.google.com) (74.125.82.65) by server-2.tower-21.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Jun 2017 17:33:43 -0000 Received: by mail-wm0-f65.google.com with SMTP id b84so13066147wmh.0 for ; Thu, 01 Jun 2017 10:33:43 -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=mEz/6sMNXWSoMeyLTwtQxLxIfyX77SQV+kJZqrujZS8=; b=Zu12sojENfaRBXZlsolpQn/CBJcV2nyV3kXZ9mVz9Z/0OV/gWHxOTLrf2eVdxX6oMc SnH0huITCteWUKsiSl/gZBP/rgb3YWk0GSK0OmwOK+FwuFSuxJedzosvl08L7vVORyps kMdL1w+9P3eCHnfOMjLgjRPfOCb/dA6usUBdT4hJZAwtURtvBB1PqIbVprT0i1D1I/wd 70qjHrOZulGCt8GMj8nXNhvgDqCXsrpaP9kROxSAdcCITFI7vV7zpeXEN4EQWdJ/jWnJ FzUydp77vKpZPawSmg+46Qgs73s3XOboqyc726dqUJqsyRun4tePNj9JABz2NnOxFZeW JOPg== 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=mEz/6sMNXWSoMeyLTwtQxLxIfyX77SQV+kJZqrujZS8=; b=Is/bqtvGxtAQw9GvkI7Z2VHPdnUi+/wRnjD7J/484JTqGj9lFtwkHrS+0K/egOCVGR hSvgrcuVCOS7wQHxbRME8egd7Lh5O89aS7rnceUuvdR/UNovt52/Y2+TY89FubVT8n8x bYycXZYc4UsRc7aLneFunnhiMM1+TbRfwA5F2YgEXOYS0jQY2h/arnJjabh3ecrciOtX rGnlo8Y3UFHSaMk2PK/D/Dggm5x76WLrmDjUp5YbopKtMrgZVwwNmPDx/2aOs2hFy6+G X2k7WZBBbz2gRe62YiOlxzSr1QSnQEAgdtOXH5lr8FzedZ8VhTB4Wb6Evzh8XBGSAK1k vgIQ== X-Gm-Message-State: AODbwcDjckGN1e0SDOy5L+BF2udPwYsjeN5M6MNA5XeYpQDi6KqrYymf PLxSBQg+cyAx9Q== X-Received: by 10.223.131.67 with SMTP id 61mr2082852wrd.37.1496338423588; Thu, 01 Jun 2017 10:33:43 -0700 (PDT) Received: from Solace.fritz.box ([80.66.223.25]) by smtp.gmail.com with ESMTPSA id 53sm28856617wrt.36.2017.06.01.10.33.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Jun 2017 10:33:42 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Thu, 01 Jun 2017 19:33:41 +0200 Message-ID: <149633842141.12814.20908893053492021.stgit@Solace.fritz.box> In-Reply-To: <149633614204.12814.14390287626133023934.stgit@Solace.fritz.box> References: <149633614204.12814.14390287626133023934.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 01/15] 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 once and for all, 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: George Dunlap Cc: Jan Beulich Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Julien Grall Cc: Tim Deegan --- 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);