Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2882312pxj; Mon, 14 Jun 2021 09:14:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJye96a9s23jFsH4jrr5rgYo8HRFc+oOWoVCvh16Z/iXjB3v/bPiXgxIWmG8R7p5k8QrmYlo X-Received: by 2002:a17:907:9688:: with SMTP id hd8mr15499193ejc.314.1623687288303; Mon, 14 Jun 2021 09:14:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623687288; cv=none; d=google.com; s=arc-20160816; b=JSNQfMcm73whlzraljtgUF/2rDVRVvb8oBFJBZINXOb2v1iVQQXI2VfBfFGzse8MO0 NWSj+AX5FM3I87DfqK4NwT3R1RBpkj1CB1Vpoq/lobJQ4mdUoVfE66NvGtWMfYUU1an6 Raeq37nTgpUYXKstBnZIbCztsaO95hRvIaXuAQyzye6UsZfH3n0enZwJvXaEn8YLzXqS dZfdlmTZJkP6Rxm2OWP9WQPEMpL2jlDIVrbneKbaKt0Jv0C9sI08jYtq5n3R9L5MwCLE B4/1Z8d5IbIw1kS9J+0REBCpKM7yFbFUfdinDpJjWPerS4S8SdohB3GENgSDggBwklCu fYoQ== 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=U/Ya1k1nXvvGjrRExG8q3FmOawUUZX1h7T0TrtPnmSM=; b=0eShOFBrW8IMXkQkABSYW+HHX5/RoAvHDehUoCQVLYpfCdbm7mXr9ehCYZcY88yrvX LzaKBvkChK3cxM8oOC4VDNoCdmn2hNId53qBu6NWa1wdqwH9NjsHiNBPr3R+0LyIMMaz 04dGqIAemvsvDA+nEAYX5O34+TMT3R0oNqCF7lgbgQpcv34jFMEeRY4cVrwgoLPD9aTI zMiTddkjPLR6laY/1+6aVOfvED5CokBmyliysC0k/GGl+KYlm+QruBGagkoZTzjQhhxI ikmEfDLtgQj71d931i7Tdp4IkR9qTPWZ/kPagZTCsxFaRvCGEwwtYP9V66OPJOdQLJXX PHhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=goCD3Qgn; 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 df25si10249450edb.145.2021.06.14.09.14.24; Mon, 14 Jun 2021 09:14:48 -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=goCD3Qgn; 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 S234579AbhFNQO6 (ORCPT + 99 others); Mon, 14 Jun 2021 12:14:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51775 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234572AbhFNQO5 (ORCPT ); Mon, 14 Jun 2021 12:14:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623687173; 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=U/Ya1k1nXvvGjrRExG8q3FmOawUUZX1h7T0TrtPnmSM=; b=goCD3QgnotXIocEKYMZfH5VHj3SH8r1CrIdjRuQFOmtK6s+T5uQqMNdX+tp8hgxvd59hUz Zw6bfEueQUOIzXiqINcQEnru9p01MTzM8XGKRMqFz0ADajzLjaxBcAW7mEhF2pvRVOYqTY qwnMqK75yMAG7Qw98a7xk8IyGizTIW8= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-282-qIrTKRU6P6yLqHvQCAisZw-1; Mon, 14 Jun 2021 12:12:52 -0400 X-MC-Unique: qIrTKRU6P6yLqHvQCAisZw-1 Received: by mail-lf1-f70.google.com with SMTP id n4-20020a0565120ac4b02902fdd8d82fa6so5435632lfu.1 for ; Mon, 14 Jun 2021 09:12:52 -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=U/Ya1k1nXvvGjrRExG8q3FmOawUUZX1h7T0TrtPnmSM=; b=Ph6qS8orHe2/kjx3CjD/S39FSa+J2bqetiICIii/WEZpHC1NDSipjYxtWU8ilse/bn lMf8alxhu8u7PYSg9BtBBcptr6OAsMkmGb/yEYwUAZcKhjATgReHSPVZpjzYnaLSwxQg U84cqpSI0+tU6ExahQTtKgL5Pt5ptmUo5eGPh1TAa14pLzIL2+cq+AM8mPbewPz7OwCN zWuo+MdBX78/xvrTQ5pTVCZgdBMdTdd1gx85240bjMGKl9TwneKcJOWFMF5ZdF/TyKkl JKj86IAQxoH1e8zpVXGulZSSDcb9/BTbHq8vyFlvKgKyak95g+LgxVFwJsj2Pcet09LN QdhQ== X-Gm-Message-State: AOAM5309Y3QAm6ejvEJKPuuQ0tUentzjrT4GohF5oOmkE6rFwjFo+neN gdpAXei3EeLnzWraDDCKjrx4y5HEgpbvbyQUabuNwOjKPvZhprHrBHxl2qS5WjOlpWK8/yb1kEO IxKO6Yo8p42QomaYRJNL2wSAHqh3iW7uKK42sqIkS X-Received: by 2002:a05:6512:2101:: with SMTP id q1mr8877569lfr.647.1623687170838; Mon, 14 Jun 2021 09:12:50 -0700 (PDT) X-Received: by 2002:a05:6512:2101:: with SMTP id q1mr8877529lfr.647.1623687170605; Mon, 14 Jun 2021 09:12:50 -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: From: Nitesh Lal Date: Mon, 14 Jun 2021 12:12:38 -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 Mon, Jun 7, 2021 at 1:00 PM Nitesh Lal wrote: > > 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'. I am going to and make the suggested changes to this patch and will post it with driver patches. Please let me know if there are any objections to that. > > > +} > > + > > 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 -- Thanks Nitesh