All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Thomas Gleixner" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Nitesh Narayan Lal <nitesh@redhat.com>,
	Ming Lei <ming.lei@redhat.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org, maz@kernel.org
Subject: [tip: irq/core] genirq: Provide new interfaces for affinity hints
Date: Fri, 10 Dec 2021 19:54:11 -0000	[thread overview]
Message-ID: <163916605172.23020.5428721347678222727.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20210501021832.743094-1-jesse.brandeburg@intel.com>

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     65c7cdedeb3026fabcc967a7aae2f755ad4d0783
Gitweb:        https://git.kernel.org/tip/65c7cdedeb3026fabcc967a7aae2f755ad4d0783
Author:        Thomas Gleixner <tglx@linutronix.de>
AuthorDate:    Fri, 03 Sep 2021 11:24:17 -04:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Fri, 10 Dec 2021 20:47:38 +01:00

genirq: Provide new interfaces for affinity hints

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 <tglx@linutronix.de>
Signed-off-by: Nitesh Narayan Lal <nitesh@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20210501021832.743094-1-jesse.brandeburg@intel.com
Link: https://lore.kernel.org/r/20210903152430.244937-2-nitesh@redhat.com

---
 include/linux/interrupt.h | 53 +++++++++++++++++++++++++++++++++++++-
 kernel/irq/manage.c       |  8 +++---
 2 files changed, 56 insertions(+), 5 deletions(-)

diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
index 1f22a30..9367f1c 100644
--- a/include/linux/interrupt.h
+++ b/include/linux/interrupt.h
@@ -329,7 +329,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
+ * @m:		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
+ * @m:		cpumask pointer (NULL to clear the hint)
+ *
+ * Updates the affinity hint and if @m 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);
 
@@ -361,6 +400,18 @@ static inline int irq_can_set_affinity(unsigned int irq)
 
 static inline int irq_select_affinity(unsigned int irq)  { return 0; }
 
+static inline int irq_update_affinity_hint(unsigned int irq,
+					   const struct cpumask *m)
+{
+	return -EINVAL;
+}
+
+static inline int irq_set_affinity_and_hint(unsigned int irq,
+					    const struct cpumask *m)
+{
+	return -EINVAL;
+}
+
 static inline int irq_set_affinity_hint(unsigned int irq,
 					const struct cpumask *m)
 {
diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index 7405e38..f23ffd3 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -486,7 +486,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);
@@ -495,12 +496,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)
 {

      parent reply	other threads:[~2021-12-10 19:54 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-01  2:18 [PATCH tip:irq/core v1] genirq: remove auto-set of the mask when setting the hint Jesse Brandeburg
2021-05-01  2:18 ` [Intel-wired-lan] " Jesse Brandeburg
2021-05-04 12:15 ` Robin Murphy
2021-05-04 12:15   ` [Intel-wired-lan] " Robin Murphy
2021-05-04 14:29   ` Nitesh Lal
2021-05-04 14:29     ` [Intel-wired-lan] " Nitesh Lal
2021-05-04 16:23   ` Jesse Brandeburg
2021-05-04 16:23     ` [Intel-wired-lan] " Jesse Brandeburg
2021-05-17 16:57     ` Nitesh Lal
2021-05-17 16:57       ` [Intel-wired-lan] " Nitesh Lal
2021-05-17 17:26       ` Robin Murphy
2021-05-17 17:26         ` [Intel-wired-lan] " Robin Murphy
2021-05-17 18:08         ` Thomas Gleixner
2021-05-17 18:08           ` [Intel-wired-lan] " Thomas Gleixner
2021-05-17 18:50           ` Robin Murphy
2021-05-17 18:50             ` [Intel-wired-lan] " Robin Murphy
2021-05-17 19:08             ` Thomas Gleixner
2021-05-17 19:08               ` [Intel-wired-lan] " Thomas Gleixner
2021-05-17 19:43               ` Thomas Gleixner
2021-05-17 19:43                 ` [Intel-wired-lan] " Thomas Gleixner
2021-05-17 20:18               ` Thomas Gleixner
2021-05-17 20:18                 ` [Intel-wired-lan] " Thomas Gleixner
2021-05-17 18:21         ` Nitesh Lal
2021-05-17 18:21           ` [Intel-wired-lan] " Nitesh Lal
2021-05-17 19:47           ` Thomas Gleixner
2021-05-17 19:47             ` [Intel-wired-lan] " Thomas Gleixner
2021-05-17 21:13             ` Nitesh Lal
2021-05-17 21:13               ` [Intel-wired-lan] " Nitesh Lal
2021-05-17 20:48     ` Thomas Gleixner
2021-05-17 20:48       ` [Intel-wired-lan] " Thomas Gleixner
2021-05-17 22:44       ` Nitesh Lal
2021-05-17 22:44         ` [Intel-wired-lan] " Nitesh Lal
2021-05-18  0:03         ` Thomas Gleixner
2021-05-18  0:03           ` [Intel-wired-lan] " Thomas Gleixner
2021-05-18  0:23           ` Nitesh Lal
2021-05-18  0:23             ` [Intel-wired-lan] " Nitesh Lal
2021-05-20 21:57             ` Nitesh Lal
2021-05-20 21:57               ` [Intel-wired-lan] " Nitesh Lal
2021-05-21  0:03               ` Nitesh Lal
2021-05-21  0:03                 ` [Intel-wired-lan] " Nitesh Lal
2021-05-21 11:56                 ` Thomas Gleixner
2021-05-21 11:56                   ` [Intel-wired-lan] " Thomas Gleixner
2021-05-21 12:03                   ` [PATCH] genirq: Provide new interfaces for affinity hints Thomas Gleixner
2021-05-21 12:03                     ` [Intel-wired-lan] " Thomas Gleixner
2021-05-21 15:45                     ` Lijun Pan
2021-05-21 15:45                       ` [Intel-wired-lan] " Lijun Pan
2021-05-21 21:45                       ` Thomas Gleixner
2021-05-21 21:45                         ` [Intel-wired-lan] " Thomas Gleixner
2021-05-21 16:13                     ` Nitesh Lal
2021-05-21 16:13                       ` [Intel-wired-lan] " Nitesh Lal
2021-05-21 21:48                       ` Thomas Gleixner
2021-05-21 21:48                         ` [Intel-wired-lan] " Thomas Gleixner
2021-06-04 20:35                         ` Nitesh Lal
2021-06-04 20:35                           ` [Intel-wired-lan] " Nitesh Lal
2021-05-27 10:03                     ` Shung-Hsi Yu
2021-05-27 10:03                       ` [Intel-wired-lan] " Shung-Hsi Yu
2021-05-27 10:21                       ` Shung-Hsi Yu
2021-05-27 10:21                         ` [Intel-wired-lan] " Shung-Hsi Yu
2021-05-27 13:06                       ` Nitesh Lal
2021-05-27 13:06                         ` [Intel-wired-lan] " Nitesh Lal
2021-05-28  7:20                         ` Shung-Hsi Yu
2021-05-28  7:20                           ` [Intel-wired-lan] " Shung-Hsi Yu
2021-06-07 17:00                     ` Nitesh Lal
2021-06-07 17:00                       ` [Intel-wired-lan] " Nitesh Lal
2021-06-14 16:12                       ` Nitesh Lal
2021-06-14 16:12                         ` [Intel-wired-lan] " Nitesh Lal
2021-05-21 13:46                   ` [PATCH tip:irq/core v1] genirq: remove auto-set of the mask when setting the hint Nitesh Lal
2021-05-21 13:46                     ` [Intel-wired-lan] " Nitesh Lal
2021-05-21 15:15                     ` Thomas Gleixner
2021-05-21 15:15                       ` [Intel-wired-lan] " Thomas Gleixner
2021-12-10 19:54 ` tip-bot2 for Thomas Gleixner [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=163916605172.23020.5428721347678222727.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=ming.lei@redhat.com \
    --cc=nitesh@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.