From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2764C433B4 for ; Fri, 9 Apr 2021 02:14:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 74ED7610F9 for ; Fri, 9 Apr 2021 02:14:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 74ED7610F9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B50606B006C; Thu, 8 Apr 2021 22:14:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC5FF6B006E; Thu, 8 Apr 2021 22:14:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 940496B0070; Thu, 8 Apr 2021 22:14:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0187.hostedemail.com [216.40.44.187]) by kanga.kvack.org (Postfix) with ESMTP id 748A36B006C for ; Thu, 8 Apr 2021 22:14:24 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 2A6C1180ACF86 for ; Fri, 9 Apr 2021 02:14:24 +0000 (UTC) X-FDA: 78011209248.16.CA7907A Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) by imf30.hostedemail.com (Postfix) with ESMTP id 1B06BE000111 for ; Fri, 9 Apr 2021 02:14:16 +0000 (UTC) Received: by mail-io1-f43.google.com with SMTP id b10so4349567iot.4 for ; Thu, 08 Apr 2021 19:14:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=Q9i3utj55rMfcASKIs0hHytGCyCVB4AFFBo8GdIry9M=; b=uTQCqAMG9HGXfiynrIccrLZKblhYHFbp2z9pCElSW5cGbey3spnTJMSYcuKS1gBRuh +lby6lSlepAV+IVQ5Z0I7FBmOVllUs9Sqm854yHjS+WoN3NebCH/DucqWDk5ZcxChkdh bYMiAXNdqoOrD6XmClcEqUb2hR6gXiEX4JYXt9+9jBR+xrVG0NJJUaZbZxQ6jalOZ/tE c5UWqPqaDYwXLEk5XaDq6pTlI16mSQm5MugBC/Eri+qXEYNGwy20xJR+NC4TQKDRVWbw u5xNwS3Z8hsyZjOWIUM0S5KB9uOOYJXSQVGaKkgxF8ZB0sS5VSQKHrdQr5ttnytt4jCv 1BWw== X-Gm-Message-State: AOAM530m6Dxvx9ge1+7MdBdbb9fCTg54ot+sOWrg+A7MGB+4OtsOBZyN YEo60HVDahaocyKJNkbJwig= X-Google-Smtp-Source: ABdhPJytOhL7B0XkwJk21PpgR0PMMZsQzUNTrZzOwPkgi09y+WjF9q4bH2WKu6J3F83V6zxNgo9dGA== X-Received: by 2002:a5e:d907:: with SMTP id n7mr9794770iop.177.1617934463152; Thu, 08 Apr 2021 19:14:23 -0700 (PDT) Received: from google.com (243.199.238.35.bc.googleusercontent.com. [35.238.199.243]) by smtp.gmail.com with ESMTPSA id s7sm523760ioj.16.2021.04.08.19.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 19:14:22 -0700 (PDT) Date: Fri, 9 Apr 2021 02:14:21 +0000 From: Dennis Zhou To: Wang Yugui Cc: Vlastimil Babka , linux-mm@kvack.org, linux-btrfs@vger.kernel.org Subject: Re: unexpected -ENOMEM from percpu_counter_init() Message-ID: References: <20210408171959.2D72.409509F4@e16-tech.com> <20210409080759.4B68.409509F4@e16-tech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210409080759.4B68.409509F4@e16-tech.com> X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 1B06BE000111 X-Stat-Signature: sm3pqmphnaei5r6ffok6ibzfuqy9187u Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf30; identity=mailfrom; envelope-from=""; helo=mail-io1-f43.google.com; client-ip=209.85.166.43 X-HE-DKIM-Result: none/none X-HE-Tag: 1617934456-764087 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Apr 09, 2021 at 08:08:00AM +0800, Wang Yugui wrote: > Hi, >=20 > > > kernel: at least 5.10.26/5.10.27/5.10.28 > > >=20 > > > This problem is triggered by our application, NOT xfstests. > > > But our applicaiton have some heavy write load just like xfstest/ge= neric/476. > > > Our application use at most 75% of memory, if still not enough,=20 > > > it will write out all buffer info to filesystem. > >=20 > > Do you use cgroups at all? If yes can you describe the workload patte= rn > > a bit. >=20 > cgroups is enabled defaultly, so cgroups is used. >=20 > This is the output of systemd-cgls, ''samtools.nipt sort -m 60G" is one > of our application. but our application is NOT cgroups-aware, and it N= OT > call any cgroup interface directly. >=20 > Control group /: > -.slice > =E2=94=9C=E2=94=80user.slice > =E2=94=82 =E2=94=94=E2=94=80user-0.slice > =E2=94=82 =E2=94=9C=E2=94=80session-55.scope > =E2=94=82 =E2=94=82 =E2=94=9C=E2=94=8048747 sshd: root [priv] > =E2=94=82 =E2=94=82 =E2=94=9C=E2=94=8048788 sshd: root@notty > =E2=94=82 =E2=94=82 =E2=94=9C=E2=94=8048795 perl -e @GNU_Parallel=3Ds= plit/_/,"use_IPC::Open3;_use_MIME::Base6... > =E2=94=82 =E2=94=82 =E2=94=9C=E2=94=8048943 samtools.nipt sort -m 60G= -T /nodetmp//nfs/biowrk/baseline.wgs2... > =E2=94=82 =E2=94=82 =E2=94=9C=E2=94=80.... > =E2=94=82 =E2=94=94=E2=94=80user@0.service > =E2=94=82 =E2=94=94=E2=94=80init.scope > =E2=94=82 =E2=94=9C=E2=94=8048775 /usr/lib/systemd/systemd --user > =E2=94=82 =E2=94=94=E2=94=8048781 (sd-pam) > =E2=94=9C=E2=94=80init.scope > =E2=94=82 =E2=94=94=E2=94=801 /usr/lib/systemd/systemd --switched-root = --system --deserialize 18 > =E2=94=94=E2=94=80system.slice > =E2=94=9C=E2=94=80rngd.service > =E2=94=82 =E2=94=94=E2=94=801577 /sbin/rngd -f --fill-watermark=3D0 > =E2=94=9C=E2=94=80irqbalance.service > =E2=94=82 =E2=94=94=E2=94=801543 /usr/sbin/irqbalance --foreground > .... >=20 >=20 > > > This problem is happen in linux kernel 5.10.x, but not happen in li= nux > > > kernel 5.4.x. It have high frequency to repduce too. > >=20 > > Ah. Can you try the following patch? > > https://lore.kernel.org/lkml/20210408035736.883861-4-guro@fb.com/ > >=20 > > Thanks, > > Dennis >=20 > kernel: kernel 5.10.28+this patch > result: yet not happen after 4 times test. > without this path, the reproduce frequency is >50% >=20 > And a question about this, > > > > > upper caller: > > > > > nofs_flag =3D memalloc_nofs_save(); > > > > > ret =3D btrfs_drew_lock_init(&root->snapshot_lock); > > > > > memalloc_nofs_restore(nofs_flag); > >=20 > > The issue is here. nofs is set which means percpu attempts an atomic > > allocation. If it cannot find anything already allocated it isn't hap= py. > > This was done before memalloc_nofs_{save/restore}() were pervasive. > >=20 > > Percpu should probably try to allocate some pages if possible even if > > nofs is set. >=20 > Should we check and pre-alloc memory inside memalloc_nofs_restore()? > another memalloc_nofs_save() may come soon. >=20 > something like this in memalloc_nofs_save()? > if (pcpu_nr_empty_pop_pages[type] < PCPU_EMPTY_POP_PAGES_LOW) > pcpu_schedule_balance_work(); >=20 Percpu does do this via a workqueue item. The issue is in v5.9 we introduced 2 types of chunks. However, the free float page number was for the total. So even if 1 chunk type dropped below, the other chunk type might have enough pages. I'm queuing this for 5.12 and will send it out assuming it does fix your problem. >=20 > by the way, this problem still happen in kernel 5.10.28+this patch. > Is this is a PANIC without OOPS? any guide for troubleshooting please. Sorry I don't follow. Above you said the problem hasn't reproed. But now you're saying it does? Does your issue still reproduce with the patch above? > > problem: > > OS/VGA console is freezed , and no call trace is outputed. > > Just some info is outputed to IPMI/dell iDRAC > > 2 | 04/03/2021 | 11:35:01 | OS Critical Stop #0x46 | Run-time crit= ical stop () | Asserted > > 3 | Linux kernel panic: Fatal excep > > 4 | Linux kernel panic: tion >=20 > Best Regards > Wang Yugui (wangyugui@e16-tech.com) > 2021/04/08 >=20 Thanks, Dennis