Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3416592pxj; Mon, 7 Jun 2021 10:04:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdVYca7k55hrO+SQe3Bt1tIDLPfiGF7d2M2oq/mHc0kB0BMb3dIw5kj5HbPIZuvy2KRx0Q X-Received: by 2002:a17:906:3b87:: with SMTP id u7mr19204008ejf.548.1623085445269; Mon, 07 Jun 2021 10:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623085445; cv=none; d=google.com; s=arc-20160816; b=vZ1c9upPAwNVBNI6Ge1Epdz1tHjeXtmm63YjmvQoEoLuKs0IPVtlM3LUVrcJ8aTeRK XO9+wzTOci/vCzlUrW564GJnQXq+/DmfJhTkVNc5417wBDwqiYV9zLCuGGcrc65BQ5r4 qGIjfvN7ti2kBEmZuIIX9YYoUBfeuoeULj3vrQUd6ckHNpIqcMLlj289Ky17zLqvN4NE wfb3iYAtiWToEa0iUf6C3JHIwx5Wldy3pBKkphimgUFJRzWKjEnTXxdV5oPT7I5WR47a gHOzzrErNnpW9FGwcAIE/DyjGNWJsdyPFlWsCfA34SdLEfgXgr/GxuL12A+WWHmhroR+ zNTw== 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=TImFWC0HTGVlVbnQIUSZh0jMNDwAtpjYOcXi7DdGfsg=; b=k2oAzuoKJv0CUr9Z437EXQ1pImfBVcEsZ9nxAuKlXmnNPVlVkzHTjoe6N3iwOBXPXr ap5Q681jIzwjggxXnoQA9KzfeSBpD48xV1q95NvVqB0v4IIup/cMqfy5MZ1ASoqYZacn bQu+ejGQdeCOFJYFKkTiQX+eErb5y5jFEeB3lWf3461Wp5aNKr4+wMjrxM7VnMMQymZm XtM97H9G8YI31d4L+oCo5SUb5okAdqmmSY9c7hNP+nrJzMyfaNNTWqjRF8Q+KxvZwZXa C/PEsLMAqIr7DUNxJlvcPCeAE3dk4LS0YymcpTbTv55fvAppVlw3RLGsgZ9hheFvEZu5 NS8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MIQwGDOo; 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 t12si15329231edc.33.2021.06.07.10.03.39; Mon, 07 Jun 2021 10:04:05 -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=MIQwGDOo; 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 S231443AbhFGRCV (ORCPT + 99 others); Mon, 7 Jun 2021 13:02:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42758 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230331AbhFGRCR (ORCPT ); Mon, 7 Jun 2021 13:02:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623085224; 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=TImFWC0HTGVlVbnQIUSZh0jMNDwAtpjYOcXi7DdGfsg=; b=MIQwGDOo8RX1/nksDoCa3lWLSRbfpOsqTTf0TG0g37/4DtxW+EH3mPoGX4STXsfFeDGPOM RbM6DDTWt0xp6n6QV8f8rejdGEf5CWi3e6h2pygiywrE5ecfsZINB0lhVIG0tOGM4G0Mov xhDN/2lLOCjDNKOGZ9U+lF3EgtHREsI= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-119-KCVOE2aWPNWYIe_3i-c-eg-1; Mon, 07 Jun 2021 13:00:19 -0400 X-MC-Unique: KCVOE2aWPNWYIe_3i-c-eg-1 Received: by mail-lj1-f199.google.com with SMTP id w8-20020a05651c1028b02900f6e4f47184so7179345ljm.5 for ; Mon, 07 Jun 2021 10:00:18 -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=TImFWC0HTGVlVbnQIUSZh0jMNDwAtpjYOcXi7DdGfsg=; b=QluJadHaz4CW+WVJ/qe6s5vZknfDzmxDS8QYld/HNF91yQOTPyxq70SpaLa/+ryWVv TTaGtMxsRyVQyZmb6EtHu0ayZyxGogiDQ4IqUm3P69Zxb7Vs3RUG58H8WqX3WE51Voac IpJUt1kDguuI7s4D5akKaTdEmD928SkLUYiRQ5PXpfNLGatoaFisEbke9FdwEGO/mKEN 2Ds+FEtiGmOXw7GInGGLCt9+g912fklFhFp+fdp2glcbIZx5Wf4KBALcYsmpsMWSV7Tg AOqmWsKL0u+xeyR6tyqfZ4ZyaS3cW6Lp+5KqQfl/6pPWSIFDPX5n5UsAC3E7h1zt6v/7 LNcw== X-Gm-Message-State: AOAM5306JHTb3QwCMAjfLtPFYRbHiRCc1oQ7XCOJg2P7ALupnbsGJSju DvLyajiTounbRh0z+Mnoxvi4WpqtMq0s6C7/fdFqkHktiWNNsO+qlVbT2gGXa6SNZmmba2Bx9mg I323P+bTD/Lsmaq8sr+kA27A9m4C8nF4gXbzOaKk1 X-Received: by 2002:a2e:580e:: with SMTP id m14mr7269747ljb.197.1623085217110; Mon, 07 Jun 2021 10:00:17 -0700 (PDT) X-Received: by 2002:a2e:580e:: with SMTP id m14mr7269730ljb.197.1623085216890; Mon, 07 Jun 2021 10:00:16 -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: Nitesh Lal Date: Mon, 7 Jun 2021 13:00:05 -0400 Message-ID: Subject: Re: [PATCH] genirq: Provide new interfaces for affinity hints To: Thomas Gleixner Cc: 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 8:03 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); > +} > + > +/** > + * 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); Another change required here, the above should be 'm' instead of '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) > { > -- Thanks Nitesh