Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1401755pxj; Fri, 21 May 2021 13:21:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx8TCzNNaLC/+iuuarnLzQXyhMi/hMOFi60jQwST+5eDI021E2NN/32ssmf5O4RomJ7npDM X-Received: by 2002:a92:6e01:: with SMTP id j1mr706903ilc.160.1621628515653; Fri, 21 May 2021 13:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621628515; cv=none; d=google.com; s=arc-20160816; b=W4UoYXBscE56YiHBZfYC3qER7q2dnzE9dDduDpZoQNpq3gVAfhJ4WelyMLNBOBSGb3 NboY4IFoOhW4gCY1T5E98briSlABKLhItvYI4jbMq1JTPmMYqQS20gqO+neuDwyhzvON LdA5nCQ1wr8keTmYYr/JlMkxibS8V79wdg3DnPfejDubVuukdUbOPGL7q2xwBrQHpS78 ERHUjtQ8CX9vLy1Au4YsKbizyTH5H7MDutLbo5DhUIOWoFmpxQK2zfIjIWWNAoas4jWq MdNqpaosUXNtafQnqNBvpiV04hloio6+tHIyseX2cQSLCfUrCIF5gC7SZjh+gOEjhIcU s69g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ybE+rWOcV+ucwWTe+ve7kEV4gSBl+BX/5ApCrfe90rw=; b=Md5P4NGqDx4692N3ABXXTyTO3Jv0pLjE8bpuLjV8kIpzNsoOqHHnGqiCKeIC7ws3uS g5GeiNmiDMr71CV9lZLUgd20FxM1ZBhQslHP49MergO0Oor9BAOLv9D6UXGPPyl3GTw5 bGPqbM7f2wMPo172Y7Z97CwNqA980gMUx0u9O8rhhuje1nJ9xmkekYcTSC4ey/+JMvNo +cn7q9IsQ/k8/+LngDQE6inWgXBFwhRW/XXFC8+DoI4m0YC2IoLt9Vm7c3YxeM4KAbhO S+WM0wRY4yYiQ5s39Nd/3ARI8gQ8LkSqzHLsKL4boRNx+7HIa1/uCTAgqowZChR+L4r8 kbtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R0cdtin5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w17si5997879iot.47.2021.05.21.13.21.43; Fri, 21 May 2021 13:21:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=R0cdtin5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237067AbhEUPqv (ORCPT + 99 others); Fri, 21 May 2021 11:46:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230221AbhEUPqq (ORCPT ); Fri, 21 May 2021 11:46:46 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5ACA2C061574; Fri, 21 May 2021 08:45:22 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id x7so1913869wrt.12; Fri, 21 May 2021 08:45:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ybE+rWOcV+ucwWTe+ve7kEV4gSBl+BX/5ApCrfe90rw=; b=R0cdtin5b3TlkzTvnKrY4wIJquYKE7FxQ2IZWoIHUOTFQofSa3Py54/1W+u37w9e2j yAJ1KR43ibT7DCS9betnCydlo8nYAb96zKmDzkZ0liBPq9hwjRJGnPBmYD/GAWU17w2B 8g2ytqYZVwJYpw2wnV6gP59VmhHERtvCeq7UVOX5r31wHPovxgXCJ2WrkYXdSrQlAe3G 9LghIMKdTJzU8aOIJVJsWXF0yU8tuo2bxYBf95igLaVUpVfd2Dfo+Lx5h/3WBoUXT59E 8Aw1fPHPvBhWEDZcGX2S7KgX/mtlx9iACWrmOmsvuyJUTXxLQqms6byXqwwJA7lPsjub d3+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ybE+rWOcV+ucwWTe+ve7kEV4gSBl+BX/5ApCrfe90rw=; b=Hm0+wz+6T0oWt/UblsQmXONvaiknhsfD8cs4uqlbqUeFPXZPqZ8FMRJtRVcHK2tuNB MrUvCEPjfuP6qZa5vE+nvtbyZRubYtBcugQHBJmT577IC7OaS8x61tz0u2H+6Yyu28uA oC+9/peZDPI2RMV8apwNOYKkmgSxfeBINQ5YJqLNxjzwJ/QyZjhN8akI2u5j4RGM0mfW 81pXdj2af4mYRjlHJRfaCwS91qibcv0Qi4EJlBTgWlE77aBzFYqbr8bqnQhoBLKMMp+3 QWhFDro/mzNJNgrK79ZuacKmchcqjpbpibwqkAibw1iKmQjVzO3yNKwe6llIDf9jmbnO TzrA== X-Gm-Message-State: AOAM531HdlrJBa9FSgRhlLK2wSyzL8/LLnpQ6+rQ7M3V/rPVaxUCvAOA rqCjeW4p6YKwhX2JRnpvEqRizcVCEzBT6r0mEH4= X-Received: by 2002:a5d:64e4:: with SMTP id g4mr10271859wri.366.1621611920951; Fri, 21 May 2021 08:45:20 -0700 (PDT) MIME-Version: 1.0 References: <20210504092340.00006c61@intel.com> <87pmxpdr32.ffs@nanos.tec.linutronix.de> <87im3gewlu.ffs@nanos.tec.linutronix.de> <87zgwo9u79.ffs@nanos.tec.linutronix.de> <87wnrs9tvp.ffs@nanos.tec.linutronix.de> In-Reply-To: <87wnrs9tvp.ffs@nanos.tec.linutronix.de> From: Lijun Pan Date: Fri, 21 May 2021 10:45:10 -0500 Message-ID: Subject: Re: [PATCH] genirq: Provide new interfaces for affinity hints To: Thomas Gleixner Cc: Nitesh Lal , Jesse Brandeburg , Robin Murphy , Marcelo Tosatti , Ingo Molnar , linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, jbrandeb@kernel.org, "frederic@kernel.org" , "juri.lelli@redhat.com" , Alex Belits , "linux-api@vger.kernel.org" , "bhelgaas@google.com" , "linux-pci@vger.kernel.org" , "rostedt@goodmis.org" , "peterz@infradead.org" , "davem@davemloft.net" , "akpm@linux-foundation.org" , "sfr@canb.auug.org.au" , "stephen@networkplumber.org" , "rppt@linux.vnet.ibm.com" , "jinyuqi@huawei.com" , "zhangshaokun@hisilicon.com" , netdev@vger.kernel.org, chris.friesen@windriver.com, Marc Zyngier , Neil Horman , pjwaskiewicz@gmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 21, 2021 at 7:48 AM Thomas Gleixner wrote: > > The discussion about removing the side effect of irq_set_affinity_hint() of > actually applying the cpumask (if not NULL) as affinity to the interrupt, > unearthed a few unpleasantries: > > 1) The modular perf drivers rely on the current behaviour for the very > wrong reasons. > > 2) While none of the other drivers prevents user space from changing > the affinity, a cursorily inspection shows that there are at least > expectations in some drivers. > > #1 needs to be cleaned up anyway, so that's not a problem > > #2 might result in subtle regressions especially when irqbalanced (which > nowadays ignores the affinity hint) is disabled. > > Provide new interfaces: > > irq_update_affinity_hint() - Only sets the affinity hint pointer > irq_apply_affinity_hint() - Set the pointer and apply the affinity to > the interrupt > > Make irq_set_affinity_hint() a wrapper around irq_apply_affinity_hint() and > document it to be phased out. > > Signed-off-by: Thomas Gleixner > Link: https://lore.kernel.org/r/20210501021832.743094-1-jesse.brandeburg@intel.com > --- > Applies on: > git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core > --- > include/linux/interrupt.h | 41 ++++++++++++++++++++++++++++++++++++++++- > kernel/irq/manage.c | 8 ++++---- > 2 files changed, 44 insertions(+), 5 deletions(-) > > --- a/include/linux/interrupt.h > +++ b/include/linux/interrupt.h > @@ -328,7 +328,46 @@ extern int irq_force_affinity(unsigned i > extern int irq_can_set_affinity(unsigned int irq); > extern int irq_select_affinity(unsigned int irq); > > -extern int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m); > +extern int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m, > + bool setaffinity); > + > +/** > + * irq_update_affinity_hint - Update the affinity hint > + * @irq: Interrupt to update > + * @cpumask: cpumask pointer (NULL to clear the hint) > + * > + * Updates the affinity hint, but does not change the affinity of the interrupt. > + */ > +static inline int > +irq_update_affinity_hint(unsigned int irq, const struct cpumask *m) > +{ > + return __irq_apply_affinity_hint(irq, m, true); > +} Should it be: return __irq_apply_affinity_hint(irq, m, false); here? > + > +/** > + * irq_apply_affinity_hint - Update the affinity hint and apply the provided > + * cpumask to the interrupt > + * @irq: Interrupt to update > + * @cpumask: cpumask pointer (NULL to clear the hint) > + * > + * Updates the affinity hint and if @cpumask is not NULL it applies it as > + * the affinity of that interrupt. > + */ > +static inline int > +irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m) > +{ > + return __irq_apply_affinity_hint(irq, m, true); > +} > + > +/* > + * Deprecated. Use irq_update_affinity_hint() or irq_apply_affinity_hint() > + * instead. > + */ > +static inline int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m) > +{ > + return irq_apply_affinity_hint(irq, cpumask); > +} > + > extern int irq_update_affinity_desc(unsigned int irq, > struct irq_affinity_desc *affinity); > > --- a/kernel/irq/manage.c > +++ b/kernel/irq/manage.c > @@ -487,7 +487,8 @@ int irq_force_affinity(unsigned int irq, > } > EXPORT_SYMBOL_GPL(irq_force_affinity); > > -int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m) > +int __irq_apply_affinity_hint(unsigned int irq, const struct cpumask *m, > + bool setaffinity) > { > unsigned long flags; > struct irq_desc *desc = irq_get_desc_lock(irq, &flags, IRQ_GET_DESC_CHECK_GLOBAL); > @@ -496,12 +497,11 @@ int irq_set_affinity_hint(unsigned int i > return -EINVAL; > desc->affinity_hint = m; > irq_put_desc_unlock(desc, flags); > - /* set the initial affinity to prevent every interrupt being on CPU0 */ > - if (m) > + if (m && setaffinity) > __irq_set_affinity(irq, m, false); > return 0; > } > -EXPORT_SYMBOL_GPL(irq_set_affinity_hint); > +EXPORT_SYMBOL_GPL(__irq_apply_affinity_hint); > > static void irq_affinity_notify(struct work_struct *work) > {