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=-3.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,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 BAF48C433ED for ; Fri, 9 Apr 2021 04:02:15 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D83A060241 for ; Fri, 9 Apr 2021 04:02:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D83A060241 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=e16-tech.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 447566B006C; Fri, 9 Apr 2021 00:02:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E5186B006E; Fri, 9 Apr 2021 00:02:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2ACD16B0070; Fri, 9 Apr 2021 00:02:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0141.hostedemail.com [216.40.44.141]) by kanga.kvack.org (Postfix) with ESMTP id 0C9256B006C for ; Fri, 9 Apr 2021 00:02:14 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B33318248047 for ; Fri, 9 Apr 2021 04:02:13 +0000 (UTC) X-FDA: 78011480946.23.879E123 Received: from out20-87.mail.aliyun.com (out20-87.mail.aliyun.com [115.124.20.87]) by imf13.hostedemail.com (Postfix) with ESMTP id BA487E000108 for ; Fri, 9 Apr 2021 04:02:09 +0000 (UTC) X-Alimail-AntiSpam:AC=CONTINUE;BC=0.04436843|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_enroll_verification|0.0051196-0.000702511-0.994178;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047208;MF=wangyugui@e16-tech.com;NM=1;PH=DS;RN=4;RT=4;SR=0;TI=SMTPD_---.JxEYHLc_1617940927; Received: from 192.168.2.112(mailfrom:wangyugui@e16-tech.com fp:SMTPD_---.JxEYHLc_1617940927) by smtp.aliyun-inc.com(10.147.41.231); Fri, 09 Apr 2021 12:02:07 +0800 Date: Fri, 09 Apr 2021 12:02:15 +0800 From: Wang Yugui To: Dennis Zhou Subject: Re: unexpected -ENOMEM from percpu_counter_init() Cc: Vlastimil Babka , linux-mm@kvack.org, linux-btrfs@vger.kernel.org In-Reply-To: References: <20210409080759.4B68.409509F4@e16-tech.com> Message-Id: <20210409120214.7BB6.409509F4@e16-tech.com> MIME-Version: 1.0 Content-Type: text/plain; charset="GB2312" X-Mailer: Becky! ver. 2.75.03 [en] X-Rspamd-Queue-Id: BA487E000108 X-Stat-Signature: nr1k4nufi6h6nuapnnte9p77yx5acd86 X-Rspamd-Server: rspam02 Received-SPF: none (e16-tech.com>: No applicable sender policy available) receiver=imf13; identity=mailfrom; envelope-from=""; helo=out20-87.mail.aliyun.com; client-ip=115.124.20.87 X-HE-DKIM-Result: none/none X-HE-Tag: 1617940929-981348 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: Hi, > 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/= generic/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 pat= tern > > > 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 o= ne > > of our application. but our application is NOT cgroups-aware, and it= NOT > > call any cgroup interface directly. > >=20 > > Control group /: > > -.slice > > =A9=C0=A9=A4user.slice > > =A9=A6 =A9=B8=A9=A4user-0.slice > > =A9=A6 =A9=C0=A9=A4session-55.scope > > =A9=A6 =A9=A6 =A9=C0=A9=A448747 sshd: root [priv] > > =A9=A6 =A9=A6 =A9=C0=A9=A448788 sshd: root@notty > > =A9=A6 =A9=A6 =A9=C0=A9=A448795 perl -e @GNU_Parallel=3Dsplit/_/,"u= se_IPC::Open3;_use_MIME::Base6... > > =A9=A6 =A9=A6 =A9=C0=A9=A448943 samtools.nipt sort -m 60G -T /nodet= mp//nfs/biowrk/baseline.wgs2... > > =A9=A6 =A9=A6 =A9=C0=A9=A4.... > > =A9=A6 =A9=B8=A9=A4user@0.service > > =A9=A6 =A9=B8=A9=A4init.scope > > =A9=A6 =A9=C0=A9=A448775 /usr/lib/systemd/systemd --user > > =A9=A6 =A9=B8=A9=A448781 (sd-pam) > > =A9=C0=A9=A4init.scope > > =A9=A6 =A9=B8=A9=A41 /usr/lib/systemd/systemd --switched-root --syste= m --deserialize 18 > > =A9=B8=A9=A4system.slice > > =A9=C0=A9=A4rngd.service > > =A9=A6 =A9=B8=A9=A41577 /sbin/rngd -f --fill-watermark=3D0 > > =A9=C0=A9=A4irqbalance.service > > =A9=A6 =A9=B8=A9=A41543 /usr/sbin/irqbalance --foreground > > .... > >=20 > >=20 > > > > This problem is happen in linux kernel 5.10.x, but not happen in = linux > > > > 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 atomi= c > > > allocation. If it cannot find anything already allocated it isn't h= appy. > > > 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 >=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 i= t > out assuming it does fix your problem. >=20 > >=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 pleas= e. >=20 > Sorry I don't follow. Above you said the problem hasn't reproed. But no= w > you're saying it does? Does your issue still reproduce with the patch > above? I'm sorry. The problem (-ENOMEM of percpu_counter_init) yet not happen with the patch(https://lore.kernel.org/lkml/20210408035736.883861-4-guro@fb.co= m/). but another problem(os freezed without call trace, PANIC without OOPS?, the reason is yet unkown) still happen. Best Regards Wang Yugui (wangyugui@e16-tech.com) 2021/04/09 >=20 > > > 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 cr= itical 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 >=20 > Thanks, > Dennis