From: Peter Zijlstra <peterz@infradead.org>
To: Xin Li <xin3.li@intel.com>
Cc: linux-kernel@vger.kernel.org,
platform-driver-x86@vger.kernel.org, iommu@lists.linux.dev,
linux-hyperv@vger.kernel.org, linux-perf-users@vger.kernel.org,
x86@kernel.org, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com,
steve.wahl@hpe.com, mike.travis@hpe.com,
dimitri.sivanich@hpe.com, russ.anderson@hpe.com,
dvhart@infradead.org, andy@infradead.org, joro@8bytes.org,
suravee.suthikulpanit@amd.com, will@kernel.org,
robin.murphy@arm.com, kys@microsoft.com, haiyangz@microsoft.com,
wei.liu@kernel.org, decui@microsoft.com, dwmw2@infradead.org,
baolu.lu@linux.intel.com, acme@kernel.org, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
namhyung@kernel.org, irogers@google.com, adrian.hunter@intel.com,
seanjc@google.com, jiangshanlai@gmail.com, jgg@ziepe.ca,
yangtiezhu@loongson.cn
Subject: Re: [PATCH 2/3] x86/vector: Replace IRQ_MOVE_CLEANUP_VECTOR with a timer callback
Date: Tue, 20 Jun 2023 09:20:47 +0200 [thread overview]
Message-ID: <20230620072047.GS4253@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20230619231611.2230-3-xin3.li@intel.com>
On Mon, Jun 19, 2023 at 04:16:10PM -0700, Xin Li wrote:
> +/*
> + * Called with vector_lock held
> + */
Instead of comments like that, I tend to add a lockdep_assert*()
statement to the same effect. Which unlike comment actually validate the
claim and since it's code it tends to not go stale like comments do.
> +static void __vector_cleanup(struct vector_cleanup *cl, bool check_irr)
> {
> struct apic_chip_data *apicd;
> struct hlist_node *tmp;
> + bool rearm = false;
lockdep_assert_held(&vector_lock);
> + hlist_for_each_entry_safe(apicd, tmp, &cl->head, clist) {
> unsigned int irr, vector = apicd->prev_vector;
>
> /*
> * Paranoia: Check if the vector that needs to be cleaned
> + * up is registered at the APICs IRR. That's clearly a
> + * hardware issue if the vector arrived on the old target
> + * _after_ interrupts were disabled above. Keep @apicd
> + * on the list and schedule the timer again to give the CPU
> + * a chance to handle the pending interrupt.
> + *
> + * Do not check IRR when called from lapic_offline(), because
> + * fixup_irqs() was just called to scan IRR for set bits and
> + * forward them to new destination CPUs via IPIs.
> */
> + irr = check_irr ? apic_read(APIC_IRR + (vector / 32 * 0x10)) : 0;
> if (irr & (1U << (vector % 32))) {
> + pr_warn_once("Moved interrupt pending in old target APIC %u\n", apicd->irq);
> + rearm = true;
> continue;
> }
> free_moved_vector(apicd);
> }
>
> + /*
> + * Must happen under vector_lock to make the timer_pending() check
> + * in __vector_schedule_cleanup() race free against the rearm here.
> + */
> + if (rearm)
> + mod_timer(&cl->timer, jiffies + 1);
> +}
> +
> +static void vector_cleanup_callback(struct timer_list *tmr)
> +{
> + struct vector_cleanup *cl = container_of(tmr, typeof(*cl), timer);
> +
> + /* Prevent vectors vanishing under us */
> + raw_spin_lock_irq(&vector_lock);
> + __vector_cleanup(cl, true);
> + raw_spin_unlock_irq(&vector_lock);
> }
next prev parent reply other threads:[~2023-06-20 7:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-19 23:16 [PATCH 0/3] Do IRQ move cleanup with a timer instead of an IPI Xin Li
2023-06-19 23:16 ` [PATCH 1/3] x86/vector: Rename send_cleanup_vector() to vector_schedule_cleanup() Xin Li
2023-06-20 16:27 ` Steve Wahl
2023-06-20 17:33 ` Li, Xin3
2023-06-19 23:16 ` [PATCH 2/3] x86/vector: Replace IRQ_MOVE_CLEANUP_VECTOR with a timer callback Xin Li
2023-06-20 7:20 ` Peter Zijlstra [this message]
2023-06-20 7:47 ` Li, Xin3
2023-06-20 8:37 ` Thomas Gleixner
2023-06-20 17:30 ` Li, Xin3
2023-06-19 23:16 ` [PATCH 3/3] tools: Get rid of IRQ_MOVE_CLEANUP_VECTOR from tools Xin Li
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=20230620072047.GS4253@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=andy@infradead.org \
--cc=baolu.lu@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=decui@microsoft.com \
--cc=dimitri.sivanich@hpe.com \
--cc=dvhart@infradead.org \
--cc=dwmw2@infradead.org \
--cc=haiyangz@microsoft.com \
--cc=hpa@zytor.com \
--cc=iommu@lists.linux.dev \
--cc=irogers@google.com \
--cc=jgg@ziepe.ca \
--cc=jiangshanlai@gmail.com \
--cc=jolsa@kernel.org \
--cc=joro@8bytes.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mike.travis@hpe.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=russ.anderson@hpe.com \
--cc=seanjc@google.com \
--cc=steve.wahl@hpe.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=tglx@linutronix.de \
--cc=wei.liu@kernel.org \
--cc=will@kernel.org \
--cc=x86@kernel.org \
--cc=xin3.li@intel.com \
--cc=yangtiezhu@loongson.cn \
/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.