Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1353774pxv; Fri, 25 Jun 2021 10:53:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzXNLqBO/H1c2RRqK28+1gqWpI4iqoKmynAEHi8KGYx0LFGX2btl/fIBewv+4OOAIsZxgC X-Received: by 2002:a92:8e04:: with SMTP id c4mr8388357ild.219.1624643607668; Fri, 25 Jun 2021 10:53:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624643607; cv=none; d=google.com; s=arc-20160816; b=UPWzXbA/8p962xebkudvKtN2rkFz4ItqY2rGcKxO6O6/K2v+dDKJugKsyCVzFr1uiX COAJqJ3j1ZPqCgXVMeb4KuvBE0slxXZzXzqvpDdnH2SCw4/CeWTOZ+gopqDK/f421DBB 8K9SCwJloyZde9BGoKCi57NfZZn5SLVBCQyoGhFkRfMWx65bEATx8Sq7dpDnYBQgWbgp sn5HlbLijPIuh3fDE31JxsliEUmtXoNPh9PkfK/O/Pw9hx36u48bqkTcRtlc0fPjMiD6 LZ/8NpxoVPST0lIPJ2+QL+47u1QfddH64oWhmwvS77migUNXWWFFVNAybv79DW2bmlD4 zifA== 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=Np0xO1RJa8Fe+o0fE+8kFFb6yFJ3EzhbKHebm61tvY8=; b=nHXwPDDchp99d7Psp1jgJ7qBE9m7kVojCgnHxtjq/8OprqLRhwixClr1SO7TvAnRKj BYVOsu+DIIrou6+XnKAg5NjXmdwHzSgugSfJZmL/27fea+4mLMj48yBMeQc0vesoXoo3 ulgkxvZb+zstLmmDWaw9H174X8+hnqIa4mFHSsLSES/KGNxi5g7eYD5R8SfgfcqB+l4/ W+1zbu929caEend6GAKb4dnZoV8/7pWz2xgzPjfhXMNNAM3tbJLW70BJAR9VMyKuBnmq 46JXGrUux1HKp6V5K5t5af3kP7ZiWCxCsPomJ9kAb3fZLgAdpGSqxtL5Dkt5qq+iExhI e3QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=P0NhBS3D; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p1si483366ios.16.2021.06.25.10.53.15; Fri, 25 Jun 2021 10:53:27 -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=@redhat.com header.s=mimecast20190719 header.b=P0NhBS3D; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230123AbhFYRys (ORCPT + 99 others); Fri, 25 Jun 2021 13:54:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31817 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbhFYRyn (ORCPT ); Fri, 25 Jun 2021 13:54:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1624643542; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Np0xO1RJa8Fe+o0fE+8kFFb6yFJ3EzhbKHebm61tvY8=; b=P0NhBS3D/ABhVu9rbdDiIPM5lEbCg/YNSqFIeG648mYtMtaasG+ZdnfInvljbOhz8d7nM8 9hb6HBnWg5j63w6xpptRBguuflYcZthYgTXbQ15g/ONFZA2nxYaTnkckD82B0w/w3OghF7 m0zRcKoQbYg3dW9kX54bygLW/V6OmN4= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-40-80OiKGhAOw-f0JYPp53SNg-1; Fri, 25 Jun 2021 13:52:20 -0400 X-MC-Unique: 80OiKGhAOw-f0JYPp53SNg-1 Received: by mail-lj1-f198.google.com with SMTP id v3-20020a2e99030000b0290144dc7b6cf0so3589275lji.2 for ; Fri, 25 Jun 2021 10:52:20 -0700 (PDT) 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=Np0xO1RJa8Fe+o0fE+8kFFb6yFJ3EzhbKHebm61tvY8=; b=JdOa024raTdz3P9HBm2OPeBXyRkljctuKw6JchfcWO3iYz5NwJyycG0MVE8QAAJtlr lO77M0TUoEx5SdgzkAGbZMnAmSg0gta/Io2gX5MQvT+UPtCvKQX9vf7YNVvaj+/vF7cf Cq49IqebmDxDR49IdIVAzWC7iNPfCKMPtyUKp5mTStRFCCFxl5ETb+DJ6eT2mtqg7EcG FDLitEP9jS5CwTVNz53lgiKmZns1rYJXkh+By7J+OVuQTwWETRYdhJ6gpzg4Jg0NHb1+ ZEDcTow/aPwa1EiDbTMWrnqmLRPhY0uedPvDisywfH8v62U4YGoEoKpS0GG8sfOad4r3 GDtg== X-Gm-Message-State: AOAM532Nm/CB8J0oQTeqfe1Y6IWFrdoONKmfQ/aEmgUxpO70gRncat/x G6mdlPHo2HiAGrsXMf+LLvRngDhX1rii23UxctXGZvY30M+wKQ/npO4cAdVC2BB9bkoHclR/ZyP +g7hoG00a01y9VL8SyOFnxekI1zYc1sKEImGOBEUu X-Received: by 2002:a05:6512:1188:: with SMTP id g8mr9091289lfr.114.1624643538646; Fri, 25 Jun 2021 10:52:18 -0700 (PDT) X-Received: by 2002:a05:6512:1188:: with SMTP id g8mr9091276lfr.114.1624643538381; Fri, 25 Jun 2021 10:52:18 -0700 (PDT) MIME-Version: 1.0 References: <20210617182242.8637-1-nitesh@redhat.com> <20210617182242.8637-2-nitesh@redhat.com> In-Reply-To: <20210617182242.8637-2-nitesh@redhat.com> From: Nitesh Lal Date: Fri, 25 Jun 2021 13:52:04 -0400 Message-ID: Subject: Re: [PATCH v1 01/14] genirq: Provide new interfaces for affinity hints To: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linux-scsi@vger.kernel.org Cc: intel-wired-lan@lists.osuosl.org, Thomas Gleixner , netdev@vger.kernel.org, linux-pci@vger.kernel.org, Jesse Brandeburg , Robin Murphy , Marcelo Tosatti , Ingo Molnar , jbrandeb@kernel.org, frederic@kernel.org, Juri Lelli , Alex Belits , Bjorn Helgaas , 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, chris.friesen@windriver.com, Marc Zyngier , Neil Horman , pjwaskiewicz@gmail.com, Stefan Assmann , Tomas Henzl , kashyap.desai@broadcom.com, Sumit Saxena , shivasharan.srikanteshwara@broadcom.com, sathya.prakash@broadcom.com, Sreekanth Reddy , suganath-prabu.subramani@broadcom.com, james.smart@broadcom.com, dick.kennedy@broadcom.com, Ken Cox , faisal.latif@intel.com, shiraz.saleem@intel.com, tariqt@nvidia.com, Alaa Hleihel , Kamal Heib , borisp@nvidia.com, saeedm@nvidia.com, benve@cisco.com, govind@gmx.com, jassisinghbrar@gmail.com, ajit.khaparde@broadcom.com, sriharsha.basavapatna@broadcom.com, somnath.kotur@broadcom.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 17, 2021 at 2:23 PM Nitesh Narayan Lal wrote: > > From: Thomas Gleixner > > 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_set_affinity_and_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 > Signed-off-by: Nitesh Narayan Lal > Link: https://lore.kernel.org/r/20210501021832.743094-1-jesse.brandeburg@intel.com > --- > include/linux/interrupt.h | 41 ++++++++++++++++++++++++++++++++++++++- > kernel/irq/manage.c | 8 ++++---- > 2 files changed, 44 insertions(+), 5 deletions(-) > > diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h > index 2ed65b01c961..4ca491a76033 100644 > --- a/include/linux/interrupt.h > +++ b/include/linux/interrupt.h > @@ -328,7 +328,46 @@ extern int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask); > 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, false); > +} > + > +/** > + * irq_set_affinity_and_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_set_affinity_and_hint(unsigned int irq, const struct cpumask *m) > +{ > + return __irq_apply_affinity_hint(irq, m, true); > +} > + > +/* > + * Deprecated. Use irq_update_affinity_hint() or irq_set_affinity_and_hint() > + * instead. > + */ > +static inline int irq_set_affinity_hint(unsigned int irq, const struct cpumask *m) > +{ > + return irq_set_affinity_and_hint(irq, m); > +} > + > extern int irq_update_affinity_desc(unsigned int irq, > struct irq_affinity_desc *affinity); > > diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c > index ef30b4762947..837b63e63111 100644 > --- a/kernel/irq/manage.c > +++ b/kernel/irq/manage.c > @@ -487,7 +487,8 @@ int irq_force_affinity(unsigned int irq, const struct cpumask *cpumask) > } > 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 irq, const struct cpumask *m) > 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) > { > -- > 2.27.0 > It turns out that this patch has an issue. The new interfaces are not added under the #ifdef (CONFIG_SMP)'s else section. I will fix it and send a v2 with other changes. -- Thanks Nitesh