All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: Usama Arif <usamaarif642@gmail.com>
Cc: Yosry Ahmed <yosryahmed@google.com>,
	 kernel test robot <oliver.sang@intel.com>,
	oe-lkp@lists.linux.dev,  lkp@intel.com,
	Linux Memory Management List <linux-mm@kvack.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	 Chengming Zhou <chengming.zhou@linux.dev>,
	Nhat Pham <nphamcs@gmail.com>,
	 David Hildenbrand <david@redhat.com>,
	"Huang, Ying" <ying.huang@intel.com>,
	 Hugh Dickins <hughd@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	 Matthew Wilcox <willy@infradead.org>,
	 Shakeel Butt <shakeel.butt@linux.dev>,
	Andi Kleen <ak@linux.intel.com>,
	 linux-kernel@vger.kernel.org
Subject: Re: [linux-next:master] [mm] 0fa2857d23: WARNING:at_mm/page_alloc.c:#__alloc_pages_noprof
Date: Mon, 24 Jun 2024 08:26:44 -0700 (PDT)	[thread overview]
Message-ID: <61d19ec8-2ba7-e156-7bb7-f746dae8e120@google.com> (raw)
In-Reply-To: <12fb19d1-3e57-4880-be59-0e83cdc4b7f1@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2392 bytes --]

On Mon, 24 Jun 2024, Usama Arif wrote:
> On 24/06/2024 15:05, Yosry Ahmed wrote:
> > On Mon, Jun 24, 2024 at 1:49 AM kernel test robot <oliver.sang@intel.com>
> > wrote:
> >>
> >>
> >> Hello,
> >>
> >> kernel test robot noticed
> >> "WARNING:at_mm/page_alloc.c:#__alloc_pages_noprof" on:
> >>
> >> commit: 0fa2857d23aa170e5e28d13c467b303b0065aad8 ("mm: store zero pages to
> >> be swapped out in a bitmap")
> >> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git master
> > This is coming from WARN_ON_ONCE_GFP(order > MAX_PAGE_ORDER, gfp), and
> > is triggered by the new bitmap_zalloc() call in the swapon path. For a
> > sufficiently large swapfile, bitmap_zalloc() (which uses kmalloc()
> > under the hood) cannot be used to allocate the bitmap.
> >
> > Usama, I think we want to use a variant of kvmalloc() here.

Yes, I hit the same problem with swapon in my testing,
and had been intending to send a patch.

> 
> Yes, just testing with below diff now. The patch is not in mm-stable yet, so
> will just send another revision with below diff included. Thanks!
> 
> 
> diff --git a/mm/swapfile.c b/mm/swapfile.c
> index 0b8270359bcf..2263f71baa31 100644
> --- a/mm/swapfile.c
> +++ b/mm/swapfile.c
> @@ -2643,7 +2643,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *,
> specialfile)
>         free_percpu(p->cluster_next_cpu);
>         p->cluster_next_cpu = NULL;
>         vfree(swap_map);
> -       bitmap_free(p->zeromap);
> +       kvfree(p->zeromap);

Yes.

>         kvfree(cluster_info);
>         /* Destroy swap account information */
>         swap_cgroup_swapoff(p->type);
> @@ -3170,7 +3170,7 @@ SYSCALL_DEFINE2(swapon, const char __user *,
> specialfile, int, swap_flags)
>                 goto bad_swap_unlock_inode;
>         }
> 
> -       p->zeromap = bitmap_zalloc(maxpages, GFP_KERNEL);
> +       p->zeromap = kvzalloc(DIV_ROUND_UP(maxpages, 8), GFP_KERNEL);

No, 8 is not right for 32-bit kernels. I think you want
	p->zeromap = kvzalloc(BITS_TO_LONGS(maxpages), GFP_KERNEL);
but please check it carefully, I'm easily confused by such conversions.

Hugh

>         if (!p->zeromap) {
>                 error = -ENOMEM;
>                 goto bad_swap_unlock_inode;

  reply	other threads:[~2024-06-24 15:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-24  8:49 [linux-next:master] [mm] 0fa2857d23: WARNING:at_mm/page_alloc.c:#__alloc_pages_noprof kernel test robot
2024-06-24 12:05 ` Yosry Ahmed
2024-06-24 13:06   ` Usama Arif
2024-06-24 15:26     ` Hugh Dickins [this message]
2024-06-24 15:39       ` Usama Arif
2024-06-24 15:55         ` Hugh Dickins
2024-06-24 16:56         ` Yosry Ahmed
2024-06-24 17:26           ` Usama Arif
2024-06-24 17:31             ` Yosry Ahmed
2024-06-24 18:26               ` Usama Arif
2024-06-27 11:05                 ` Usama Arif
2024-06-24 18:33   ` Matthew Wilcox
2024-06-24 18:50     ` Usama Arif
2024-06-24 18:53       ` Yosry Ahmed
2024-06-24 18:54       ` Matthew Wilcox
2024-06-24 18:53     ` Yosry Ahmed
2024-06-24 18:56       ` Matthew Wilcox
2024-06-24 18:57         ` Yosry Ahmed
2024-06-24 19:26           ` Matthew Wilcox
2024-06-24 19:34             ` Yosry Ahmed
2024-06-24 19:50               ` Matthew Wilcox
2024-06-24 20:39                 ` Shakeel Butt
2024-06-24 20:51                   ` Matthew Wilcox
2024-06-24 21:02                     ` Shakeel Butt

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=61d19ec8-2ba7-e156-7bb7-f746dae8e120@google.com \
    --to=hughd@google.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=chengming.zhou@linux.dev \
    --cc=david@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lkp@intel.com \
    --cc=nphamcs@gmail.com \
    --cc=oe-lkp@lists.linux.dev \
    --cc=oliver.sang@intel.com \
    --cc=shakeel.butt@linux.dev \
    --cc=usamaarif642@gmail.com \
    --cc=willy@infradead.org \
    --cc=ying.huang@intel.com \
    --cc=yosryahmed@google.com \
    /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.