From patchwork Fri Aug 18 18:04:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9909695 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 7350E60385 for ; Fri, 18 Aug 2017 18:06:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C45928D14 for ; Fri, 18 Aug 2017 18:06:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6135728D1D; Fri, 18 Aug 2017 18:06:30 +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 58E7128D18 for ; Fri, 18 Aug 2017 18:06:28 +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 1dilcz-0002By-VA; Fri, 18 Aug 2017 18:04:13 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dilcy-0002Bi-Fo for xen-devel@lists.xenproject.org; Fri, 18 Aug 2017 18:04:12 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 76/6A-01724-B1C27995; Fri, 18 Aug 2017 18:04:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDIsWRWlGSWpSXmKPExsVyMbThoK60zvR Ig6+vmC2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyu5fsZCx6LVEx7mtLA2C7YxcjFISQwk1Fi 1dPPzCAOi8AaVomzd7+zgTgSApdYJZZPXA7kcAI5cRKb23uAqjiA7GqJ1xPAwkICKhI3t69ig pj0lVHixaXrjCAJYQE9iSNHf7BD2JESh/a/Ygax2QQMJN7s2MsKYosIKEncWzUZrJlZYDaTxJ WZN1hAFrAIqEpcmhYPUsMr4CPRsOACE4jNCWS/uHiCFWKxt8S73ytYQGxRATmJlZdbWCHqBSV OznwCNoZZQFNi/S59kDCzgLzE9rdzmCcwisxCUjULoWoWkqoFjMyrGNWLU4vKUot0TfWSijLT M0pyEzNzdA0NjPVyU4uLE9NTcxKTivWS83M3MQJDv56BgXEH4+WvTocYJTmYlER5f8+aEinEl 5SfUpmRWJwRX1Sak1p8iFGGg0NJgjdaa3qkkGBRanpqRVpmDjAKYdISHDxKIryPQNK8xQWJuc WZ6RCpU4yWHFeurPvCxLFh9XogOeXA9i9MQix5+XmpUuK8JSANAiANGaV5cONgieISo6yUMC8 jAwODEE9BalFuZgmq/CtGcQ5GJWHeZpApPJl5JXBbXwEdxAR0kGHrNJCDShIRUlINjFFTtl3I OPbq/6s3F1++m/iwd5VHMMezq4skV7Ny22+bcbE7Wjto+62ZqezxF/I2/1163M7suPL94++vH ljztEdNjqto5bwtbyyvGQerHVQSj66bdO7dsZvTNHd2Sdr9tztq2iXHOaFm5YLEpnovvfWl5m s2aTwQMnWK06/wmlO6cH7edKZVD04qsRRnJBpqMRcVJwIAF8FidA8DAAA= X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-2.tower-31.messagelabs.com!1503079450!98955841!1 X-Originating-IP: [209.85.128.193] 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 24599 invoked from network); 18 Aug 2017 18:04:11 -0000 Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by server-2.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Aug 2017 18:04:11 -0000 Received: by mail-wr0-f193.google.com with SMTP id z91so10949236wrc.4 for ; Fri, 18 Aug 2017 11:04:11 -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=UyoDRyacSHHvE6PUY91iCUzMRmwORyQbQmD2+aWVVX68Kdw1mfQt/BcKDR71J1/PT3 t0oqT3VFDqGrgXkbJ50jVBZDC9ws+z0sD6wMWVM/Pyq8e9JYaYGMQlpr+GrFTTSlQtMI E6CGrsshocFA8kYuxB3snRIvUH35Mg6y2pgxXuIM6scTKnaDap7iy+nPcql1dIFx+g65 qW2/tVVRHbu2FoyXwgv+auC/wb+GQ8x5o47VZNc//mOMsFz+ExUJvipUIPtJFRTBz6S2 FuvKwQ39BAoe4e9RVnwoaueX6Mt/MXoXa/BOlgM0fG/RNilVNayVBLoJLkD0b8xetIPL pKqA== 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=PhQJr+m1szuLaX7CYaV77r/DGgNITDnAqGrVN1tNEGUzNvzIAI/9Yg2yhkjIAHRyt3 FfrUBEq6soD9e6POrywepbpg/oRl/s1S6qKRKJ7L45A2KP64gUdvUgn/IfAdmXwJlEZm Int7uMneKqz6yylExmJZXZQKdl6JQoloZbsvKnToTrEGJchc3qF35v3kJHA85gdzrHII pIzjaA1ZAllBrKyBBdliDiJIw8ncR5d011biEt2dMuFjmZ2jxl630qKefipHxnDM74Xq F6FOm3mk046O2ooKjK2Lyy9chC/qniDIQ5JkCWiWBpo6PDukXUEr8QPOiJ8qPyfba1bk ytlA== X-Gm-Message-State: AHYfb5gtMVoZ0PIq+VQvZz00l5x4un8DnAKHtJU6NYdXJoVARL9dmkBv mBze1b/CBOGohA== X-Received: by 10.223.136.104 with SMTP id e37mr1732678wre.152.1503079450494; Fri, 18 Aug 2017 11:04:10 -0700 (PDT) Received: from Solace.fritz.box ([80.66.223.3]) by smtp.gmail.com with ESMTPSA id 5sm7570209wre.5.2017.08.18.11.04.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Aug 2017 11:04:09 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Fri, 18 Aug 2017 20:04:08 +0200 Message-ID: <150307944811.29525.17246395290922089132.stgit@Solace.fritz.box> In-Reply-To: <150307710991.29525.3681195976643263117.stgit@Solace.fritz.box> References: <150307710991.29525.3681195976643263117.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 v3 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);