[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v13 04/14] xen/percpu: defer freeing per-CPU areas after resume failures


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Mykola Kvach <xakep.amatop@xxxxxxxxx>
  • Date: Mon, 16 Nov 2026 17:15:43 +0200
  • Arc-authentication-results: i=1; mx.google.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=xreGGvHmp7BFTOpuP/eDux0gdC8b+52qsTKyGm3WBhs=; fh=JawDij6L4UQ7rM+oaxbNI2C9l2y4YUH+di7F6HkBxh8=; b=bwqi7ArNq+jbUz9KS1HjM6+qByAgfi0gN51bA3Onkihu1CyizqCmJpnKedVGC2AGzo 4tCYVabjBYHGwWnDbt9Cqp8b6W+b4FaltO/wc+YeaexQPtwTJMRIfdALetLZdh2Vp/BZ PSkLvIbq8FKUjk5GAn6c1Poava19MDQbOnUMb1ajiy1wj1236kmXD81pRaR4cvBIyt5J RoZhwZwE0tHDIqD0h+MSJCw2PmvpKVZLeI6HkbA2mnOPEtLxqDwj+Ua3B+VsYNM75iZ7 tlosAXrYwP/iIK9L5ahStP2US5B4LLAi+bIzuvvaIsWdjGCH62QmDv/VwuUf/4PBtALo LmgA==; darn=lists.xenproject.org
  • Arc-seal: i=1; a=rsa-sha256; t=1794842155; cv=none; d=google.com; s=arc-20260327; b=NuzxEuub57B/MI+DCWaBn+4h1Xmb+oCDt4CAmYQSIcNXSHjl7sGRxpgfzZh7MUngap H1oLjRBnM2n3Nxa7qW0iwtd/EBiYnXeKa0Lf9XIUAqG6aVY7XypiyekhGNfjHggbD/uA YQHBdri7Tyq7/zn5oKnhqUOxvbA3Jhdz6u6ofHdMXJ0eOUBE9YjR8pzMvj/8kILLTJzH YDJM1by5w86roYxLdkp+/zqs7jIm2TK1/zJJIaOsyRU3k1hjI3jWHdg6HdfNEMEhBNIN eCdOGjNQrO0wdMGfSpz+iWjk9zP1U8dI43m5sg6yXL0ihIxdF6tE29AioM0UQ9TIYEMq eiaQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References:MIME-Version"
  • Cc: Mykola Kvach <mykola_kvach@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 16 Nov 2026 15:16:04 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hi Jan,

Thank you for the review.

On Tue, Nov 10, 2026 at 1:03 PM Jan Beulich <jbeulich@xxxxxxxx> wrote:
>
> On 27.10.2026 22:05, Mykola Kvach wrote:
> > When a CPU fails to come back during system resume, cpu_up() sends
> > CPU_UP_CANCELED. After trying the other CPUs, enable_nonboot_cpus()
> > sends CPU_RESUME_FAILED for the same CPU.
> >
> > On architectures which do not park offline CPUs, both notifications
> > queue free_percpu_area(). The release metadata, including the rcu_head,
> > is stored in that CPU's per-CPU area. The first callback may already
> > have freed the area when the second notification arrives, or the same
> > rcu_head may be queued twice. The CPU_RESUME_FAILED callbacks also need
> > the area to clean up timers and CPU-pool state.
>
> I think there's another change needed, for the change you presently do
> to not cause a leak: If enable_nonboot_cpus() calls cpu_up() for a CPU
> whose bit isn't set in frozen_cpus, and if that call fails, the CPU
> later wouldn't have the CPU_RESUME_FAILED notification sent for it.
> IOW the freeing would then not happen at all. Question is whether
> simply setting the bit in frozen_cpus would be correct: Notify
> handlers may not expect CPU_RESUME_FAILED for a CPU which wasn't
> online at the point of suspend.

CPUs outside frozen_cpus are only tried when park_offline_cpus is true.
In that case, the existing !park_offline_cpus check already prevents
freeing their per-CPU areas.

When park_offline_cpus is false, CPUs outside frozen_cpus are skipped.
A failed cpu_up() leaves the bit set, so CPU_RESUME_FAILED is sent.

Am I missing a case where this patch would introduce a leak?

>
> > --- a/xen/common/percpu.c
> > +++ b/xen/common/percpu.c
> > @@ -82,6 +82,15 @@ static int cf_check cpu_percpu_callback(
> >          break;
> >
> >      case CPU_UP_CANCELED:
> > +        /*
> > +         * On resume, CPU_RESUME_FAILED is sent after all CPUs have been
> > +         * tried. Keep the area alive for its cleanup callbacks and let
> > +         * that notification release it.
> > +         */
> > +        if ( system_state == SYS_STATE_resume )
> > +            break;
> > +        fallthrough;
> > +
> >      case CPU_DEAD:
> >      case CPU_RESUME_FAILED:
> >          if ( !park_offline_cpus && system_state != SYS_STATE_suspend )
>
> Nit: While generally we want blank lines between non-fall-through
> case blocks, imo between fall-through ones such blank lines would
> better be omitted, to make the falling through visually easier to
> notice.

Agreed, I'll remove the blank line after fallthrough.

Best regards,
Mykola

>
> Jan
>



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.