From patchwork Thu Jul 27 08:01:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Faggioli X-Patchwork-Id: 9866411 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 974EF6038C for ; Thu, 27 Jul 2017 08:03:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8940D28780 for ; Thu, 27 Jul 2017 08:03:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DB2628796; Thu, 27 Jul 2017 08:03:58 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,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 74DA228780 for ; Thu, 27 Jul 2017 08:03:57 +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 1dadjP-0000Ch-EU; Thu, 27 Jul 2017 08:01:15 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dadjO-0000CV-V9 for xen-devel@lists.xenproject.org; Thu, 27 Jul 2017 08:01:15 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id 48/53-18997-ACD99795; Thu, 27 Jul 2017 08:01:14 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDIsWRWlGSWpSXmKPExsVyMbThoO6JuZW RBmtbNS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oyu5fsZCx6LVEx7mtLA2C7YxcjFISQwk1Fi RmsnK4jDIrCGVeLduxtsXYycHBICl1glHty0g7DjJNY+uMMOYVdJfPy6kRnEFhJQkbi5fRUTx KRfjBKNi0+ygCSEBfQkjhz9wQ5hh0n8XjodrIFNwEDizY69rCC2iICSxL1Vk8GamQVmM0lcmX kDqJkD6AxViY37nUFMXgFHif4dkiDlnALOEpdPbGCB2OskcXrXKrA7RQXkJFZebgEbySsgKHF y5hOwKcwCmhLrd+mDhJkF5CW2v53DPIFRZBaSqlkIVbOQVC1gZF7FqFGcWlSWWqRraKCXVJSZ nlGSm5iZA+SZ6uWmFhcnpqfmJCYV6yXn525iBIY+AxDsYFwz1fkQoyQHk5Io7yTTikghvqT8l MqMxOKM+KLSnNTiQ4wyHBxKErzhcyojhQSLUtNTK9Iyc4BRCJOW4OBREuG1BEnzFhck5hZnpk OkTjFacly5su4LE8eG1euB5JQD278wCbHk5eelSonzzgNpEABpyCjNgxsHSxSXGGWlhHkZgQ4 U4ilILcrNLEGVf8UozsGoJMzrBjKFJzOvBG7rK6CDmIAOmtgEdlBJIkJKqoHRxezDrc3nz5fp H/z40c/6V+fyY3fPt0hIG3JVvCq/t9+jd5kcd8iBNxerOo4uYzr3+9fyJ5rVcdnTTv565BkkY /mSQ+2LxsoGnQvvH0tVu5rJq25ym/519vfv+WedGn06qjPerlmcZ77H6cU8jQfnVB/Pym+JWT vXQ/X7Plv21Q3fNsmf3WQYr8RSnJFoqMVcVJwIAP6hYb4PAwAA X-Env-Sender: raistlin.df@gmail.com X-Msg-Ref: server-11.tower-206.messagelabs.com!1501142472!84942222!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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23048 invoked from network); 27 Jul 2017 08:01:12 -0000 Received: from mail-wr0-f193.google.com (HELO mail-wr0-f193.google.com) (209.85.128.193) by server-11.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 27 Jul 2017 08:01:12 -0000 Received: by mail-wr0-f193.google.com with SMTP id y43so23725828wrd.0 for ; Thu, 27 Jul 2017 01:01:12 -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=YE1pwdXhV+quB8KsPRN/mGZYaQljNAAvA6ujWMpmjsBZzaG6MGeo2Q+RgW/TtsQpu/ XVQV/1hpf3pGcM959mA6rXjsoQDaIzeLcItg4dIGsUMw+Hk+/8f2pIAEepRuflJqJOL+ FJ2yHdXnVnwPGPmqne3Hpy2NBP99msfV3F7dzCCbqqrOB/SLLrfyqmXayvQsGSlG8WVy IegqfVUteYiL1jwM0VHo02/wXMsM19tZaVvEUXGufjDsY1xYDYYEzcM8kj3vR3C0sfSW cGS/6DHuT5rIevOjJx35InJTzRezJPdOt/dTYXj3ghtBs1lbXdqu48LwJBVQBpLrMWMm ZMIQ== 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=FYaJtgO/+ICwtlUVQYbO2+CXtE53Ah0vpkmUG6Nni+Y7UIf9lNgskwttgTtYhNI5Sz 2XJRIsoPJ38/nQP7P1svWhsKdssgePHBeNivHaA1rmj6kccMmCAiykV5kZxiUpgjuKWq PA6cFqu7iXsQViabNy/Zzjl+LvjmzPodkMl+opJPpNBK4DBanqLh048DKixINl1qYvxe +d3IoFJFcrRQABl7/kZJe/pz1+FYASxFFh49ITKU50bhoUn7aYQhc1QPeN7U0GxijOGi LnKUEU/sll0fX7QIlNkurcA0an3P/RaPpXP3yKqXyJ9eaOFW3VR+Fjjqjiq/a/jiclZk VI8g== X-Gm-Message-State: AIVw112LDgaXFkIsRPok/Rr11HkXbQa09sLrlfNr5zrAysXL5qHNPLz6 MsaxvQw1QFMP6A== X-Received: by 10.223.166.68 with SMTP id k62mr2639372wrc.283.1501142472233; Thu, 27 Jul 2017 01:01:12 -0700 (PDT) Received: from [192.168.0.31] ([80.66.223.212]) by smtp.gmail.com with ESMTPSA id z190sm16443795wmz.31.2017.07.27.01.01.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Jul 2017 01:01:11 -0700 (PDT) From: Dario Faggioli To: xen-devel@lists.xenproject.org Date: Thu, 27 Jul 2017 10:01:10 +0200 Message-ID: <150114247011.22910.8748737009029672283.stgit@Solace> In-Reply-To: <150114201043.22910.12807057883146318803.stgit@Solace> References: <150114201043.22910.12807057883146318803.stgit@Solace> 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 1/5] 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);