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.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS 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 55945C433E0 for ; Thu, 21 May 2020 02:40:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 28CB120758 for ; Thu, 21 May 2020 02:40:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JIZNHQnm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727983AbgEUCkE (ORCPT ); Wed, 20 May 2020 22:40:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727798AbgEUCkD (ORCPT ); Wed, 20 May 2020 22:40:03 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27CCBC061A0E; Wed, 20 May 2020 19:40:02 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id y17so3336509ilg.0; Wed, 20 May 2020 19:40:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/RCzazjPJQ1zcfvr5ivU8gZ2oW1vvouNHyaX2fPjs5o=; b=JIZNHQnmERaJeRhfnEjjac0W+vknvOwLXY/d6ercTVMilrrz524WChiYGwFGcaHgFJ K8JZk1i5INW6EyIXuYOyX2v32bfw6qRfgzQTQHHULRWMhQsYMBm89glhPbVBx2I6bwxs j20/Yum6NRQKLWYNIxFRjPx0QViHZTbPlmI1fZzO6exUlTKfLwEVLiDwpVb7Qfp6TgJ/ snhs+KlBeHyRitCTHyRBIFjZ454fFCb9qrYuro47/SQk4QgBQgus3sRPgPYvG8W/Vui1 AknW2UXV00QW+opr5rDKKkCPY+BNrd0MlLO7V3cFfkCwusagGNkXGNtRMJgA5pK9QeWA IAFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/RCzazjPJQ1zcfvr5ivU8gZ2oW1vvouNHyaX2fPjs5o=; b=TWTHK1Mul5Ro/PhNgWzqWNYPt0nJuLsbNFOVNMtrDHKeUNy5e3Wh4KgXabrwfejQa4 feGQUIrWta/+x1iWMMKkF95BTmX22rdt+eaMHB2HnUkoBYGSK/Hu9KHbjv+BmPIoH6+n MxAmTa8gLVNgzNGUEm32kaHaJYGHO8DYUO4jiB7cEoJwQyVAuC8rLYdbpC6arSWPo3K6 Bgqcm/kcW5i+XRLJd6gjF3FiPga6q49LJs2Mgj6IFDBPg7QaPPNEhs8PSWHouj3hSFKC IVcPeYPuZJwkrw4dqoILxGW0DGCfBC0jvyl98CnOG3p+/AhoxnPTh8l9IaZhrNuYJihJ r98g== X-Gm-Message-State: AOAM53084UvGaeHRrgPwSB/V1GuYkpGv69xr+89HIfFpfscv5Ue+oW+Z KgqQtQd3+FqBTBWZX8nQAlxvdPiSsKFL7f9z2FM= X-Google-Smtp-Source: ABdhPJyv/UYZjPy/DPwJRsYbSaKbImcwHJUxF5BT675dGaD56oiGCZioxLSjEnZKhN7916a+tUgfDxQbE7d+nnFanoQ= X-Received: by 2002:a92:9e11:: with SMTP id q17mr6952459ili.137.1590028801270; Wed, 20 May 2020 19:40:01 -0700 (PDT) MIME-Version: 1.0 References: <20200501135806.4eebf0b92f84ab60bba3e1e7@linux-foundation.org> <20200519075213.GF32497@dhcp22.suse.cz> <20200519084535.GG32497@dhcp22.suse.cz> In-Reply-To: From: Yafang Shao Date: Thu, 21 May 2020 10:39:25 +0800 Message-ID: Subject: Re: mm: mkfs.ext4 invoked oom-killer on i386 - pagecache_get_page To: Naresh Kamboju Cc: Chris Down , Michal Hocko , Anders Roxell , "Linux F2FS DEV, Mailing List" , linux-ext4 , linux-block , Andrew Morton , open list , Linux-Next Mailing List , linux-mm , Arnd Bergmann , Andreas Dilger , Jaegeuk Kim , "Theodore Ts'o" , Chao Yu , Hugh Dickins , Andrea Arcangeli , Matthew Wilcox , Chao Yu , lkft-triage@lists.linaro.org, Johannes Weiner , Roman Gushchin , Cgroups Content-Type: text/plain; charset="UTF-8" Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On Thu, May 21, 2020 at 2:00 AM Naresh Kamboju wrote: > > On Wed, 20 May 2020 at 17:26, Naresh Kamboju wrote: > > > > > > This issue is specific on 32-bit architectures i386 and arm on linux-next tree. > > As per the test results history this problem started happening from > > Bad : next-20200430 > > Good : next-20200429 > > > > steps to reproduce: > > dd if=/dev/disk/by-id/ata-SanDisk_SSD_PLUS_120GB_190504A00573 > > of=/dev/null bs=1M count=2048 > > or > > mkfs -t ext4 /dev/disk/by-id/ata-SanDisk_SSD_PLUS_120GB_190804A00BE5 > > > > > > Problem: > > [ 38.802375] dd invoked oom-killer: gfp_mask=0x100cc0(GFP_USER), > > order=0, oom_score_adj=0 > > As a part of investigation on this issue LKFT teammate Anders Roxell > git bisected the problem and found bad commit(s) which caused this problem. > > The following two patches have been reverted on next-20200519 and retested the > reproducible steps and confirmed the test case mkfs -t ext4 got PASS. > ( invoked oom-killer is gone now) > > Revert "mm, memcg: avoid stale protection values when cgroup is above > protection" > This reverts commit 23a53e1c02006120f89383270d46cbd040a70bc6. > > Revert "mm, memcg: decouple e{low,min} state mutations from protection > checks" > This reverts commit 7b88906ab7399b58bb088c28befe50bcce076d82. > My guess is that we made the same mistake in commit "mm, memcg: decouple e{low,min} state mutations from protection checks" that it read a stale memcg protection in mem_cgroup_below_low() and mem_cgroup_below_min(). Bellow is a possble fix, diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 7a2c56fc..6591b71 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -391,20 +391,28 @@ static inline unsigned long mem_cgroup_protection(struct mem_cgroup *root, void mem_cgroup_calculate_protection(struct mem_cgroup *root, struct mem_cgroup *memcg); -static inline bool mem_cgroup_below_low(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_low(struct mem_cgroup *root, + struct mem_cgroup *memcg) { if (mem_cgroup_disabled()) return false; + if (root == memcg) + return false; + return READ_ONCE(memcg->memory.elow) >= page_counter_read(&memcg->memory); } -static inline bool mem_cgroup_below_min(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_min(struct mem_cgroup *root, + struct mem_cgroup *memcg) { if (mem_cgroup_disabled()) return false; + if (root == memcg) + return false; + return READ_ONCE(memcg->memory.emin) >= page_counter_read(&memcg->memory); } @@ -896,12 +904,14 @@ static inline void mem_cgroup_calculate_protection(struct mem_cgroup *root, { } -static inline bool mem_cgroup_below_low(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_low(struct mem_cgroup *root, + struct mem_cgroup *memcg) { return false; } -static inline bool mem_cgroup_below_min(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_min(struct mem_cgroup *root, + struct mem_cgroup *memcg) { return false; } diff --git a/mm/vmscan.c b/mm/vmscan.c index c71660e..fdcdd88 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2637,13 +2637,13 @@ static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc) mem_cgroup_calculate_protection(target_memcg, memcg); - if (mem_cgroup_below_min(memcg)) { + if (mem_cgroup_below_min(target_memcg, memcg)) { /* * Hard protection. * If there is no reclaimable memory, OOM. */ continue; - } else if (mem_cgroup_below_low(memcg)) { + } else if (mem_cgroup_below_low(target_memcg, memcg)) { /* * Soft protection. * Respect the protection only as long as > i386 test log shows mkfs -t ext4 pass > https://lkft.validation.linaro.org/scheduler/job/1443405#L1200 > > ref: > https://lore.kernel.org/linux-mm/cover.1588092152.git.chris@chrisdown.name/ > https://lore.kernel.org/linux-mm/CA+G9fYvzLm7n1BE7AJXd8_49fOgPgWWTiQ7sXkVre_zoERjQKg@mail.gmail.com/T/#t > > -- > Linaro LKFT > https://lkft.linaro.org -- Thanks Yafang 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.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,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 D6479C433E1 for ; Thu, 21 May 2020 02:40:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 81AC620709 for ; Thu, 21 May 2020 02:40:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JIZNHQnm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 81AC620709 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2A82480008; Wed, 20 May 2020 22:40:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2591680007; Wed, 20 May 2020 22:40:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16FD180008; Wed, 20 May 2020 22:40:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0050.hostedemail.com [216.40.44.50]) by kanga.kvack.org (Postfix) with ESMTP id 00AFE80007 for ; Wed, 20 May 2020 22:40:02 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9AB2F180AD81D for ; Thu, 21 May 2020 02:40:02 +0000 (UTC) X-FDA: 76839171444.19.scent73_74b8213d9580c X-HE-Tag: scent73_74b8213d9580c X-Filterd-Recvd-Size: 8676 Received: from mail-il1-f196.google.com (mail-il1-f196.google.com [209.85.166.196]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Thu, 21 May 2020 02:40:01 +0000 (UTC) Received: by mail-il1-f196.google.com with SMTP id w18so5487554ilm.13 for ; Wed, 20 May 2020 19:40:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/RCzazjPJQ1zcfvr5ivU8gZ2oW1vvouNHyaX2fPjs5o=; b=JIZNHQnmERaJeRhfnEjjac0W+vknvOwLXY/d6ercTVMilrrz524WChiYGwFGcaHgFJ K8JZk1i5INW6EyIXuYOyX2v32bfw6qRfgzQTQHHULRWMhQsYMBm89glhPbVBx2I6bwxs j20/Yum6NRQKLWYNIxFRjPx0QViHZTbPlmI1fZzO6exUlTKfLwEVLiDwpVb7Qfp6TgJ/ snhs+KlBeHyRitCTHyRBIFjZ454fFCb9qrYuro47/SQk4QgBQgus3sRPgPYvG8W/Vui1 AknW2UXV00QW+opr5rDKKkCPY+BNrd0MlLO7V3cFfkCwusagGNkXGNtRMJgA5pK9QeWA IAFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/RCzazjPJQ1zcfvr5ivU8gZ2oW1vvouNHyaX2fPjs5o=; b=k+kDXyAG3i6WBk30euVvm8ro0yNpL+k8e0yQfXTwePkdKIx4/99QKV9vbqqdfzLN+J iXvbQKEqGhZJDvTfABd6O1hDkZ3v42bDEua1k1qd00EAbyr8qRiARG1d2CD7V5Fo4hIk TKCviWJuaOv73C5AXal6sgzlYg/qmrJb43ZkRhCWLF0BmIX2Us3KUzXZHZAv9wpjTojj r2zVujHbRD31UbBWqJjHJLkaQGPL334udJCCatZPQVX+rKdpsSc7KnUL25ysim+iqR34 5EWwAPhPsceQBFweTI2UMPa8hz2S6T7jtbciuW90pxzLfeG6qCHCBjX5KcRXwcZZjyX7 FjXA== X-Gm-Message-State: AOAM531ch49kfl1Z4AD3PIx/QNqmz50JfrwoP4jvZO3IvATmxq7vzLov DUTtAzEROAyMvKB5pQujHr5XNZ8k2zd505YIe58= X-Google-Smtp-Source: ABdhPJyv/UYZjPy/DPwJRsYbSaKbImcwHJUxF5BT675dGaD56oiGCZioxLSjEnZKhN7916a+tUgfDxQbE7d+nnFanoQ= X-Received: by 2002:a92:9e11:: with SMTP id q17mr6952459ili.137.1590028801270; Wed, 20 May 2020 19:40:01 -0700 (PDT) MIME-Version: 1.0 References: <20200501135806.4eebf0b92f84ab60bba3e1e7@linux-foundation.org> <20200519075213.GF32497@dhcp22.suse.cz> <20200519084535.GG32497@dhcp22.suse.cz> In-Reply-To: From: Yafang Shao Date: Thu, 21 May 2020 10:39:25 +0800 Message-ID: Subject: Re: mm: mkfs.ext4 invoked oom-killer on i386 - pagecache_get_page To: Naresh Kamboju Cc: Chris Down , Michal Hocko , Anders Roxell , "Linux F2FS DEV, Mailing List" , linux-ext4 , linux-block , Andrew Morton , open list , Linux-Next Mailing List , linux-mm , Arnd Bergmann , Andreas Dilger , Jaegeuk Kim , "Theodore Ts'o" , Chao Yu , Hugh Dickins , Andrea Arcangeli , Matthew Wilcox , Chao Yu , lkft-triage@lists.linaro.org, Johannes Weiner , Roman Gushchin , Cgroups Content-Type: text/plain; charset="UTF-8" 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 Thu, May 21, 2020 at 2:00 AM Naresh Kamboju wrote: > > On Wed, 20 May 2020 at 17:26, Naresh Kamboju wrote: > > > > > > This issue is specific on 32-bit architectures i386 and arm on linux-next tree. > > As per the test results history this problem started happening from > > Bad : next-20200430 > > Good : next-20200429 > > > > steps to reproduce: > > dd if=/dev/disk/by-id/ata-SanDisk_SSD_PLUS_120GB_190504A00573 > > of=/dev/null bs=1M count=2048 > > or > > mkfs -t ext4 /dev/disk/by-id/ata-SanDisk_SSD_PLUS_120GB_190804A00BE5 > > > > > > Problem: > > [ 38.802375] dd invoked oom-killer: gfp_mask=0x100cc0(GFP_USER), > > order=0, oom_score_adj=0 > > As a part of investigation on this issue LKFT teammate Anders Roxell > git bisected the problem and found bad commit(s) which caused this problem. > > The following two patches have been reverted on next-20200519 and retested the > reproducible steps and confirmed the test case mkfs -t ext4 got PASS. > ( invoked oom-killer is gone now) > > Revert "mm, memcg: avoid stale protection values when cgroup is above > protection" > This reverts commit 23a53e1c02006120f89383270d46cbd040a70bc6. > > Revert "mm, memcg: decouple e{low,min} state mutations from protection > checks" > This reverts commit 7b88906ab7399b58bb088c28befe50bcce076d82. > My guess is that we made the same mistake in commit "mm, memcg: decouple e{low,min} state mutations from protection checks" that it read a stale memcg protection in mem_cgroup_below_low() and mem_cgroup_below_min(). Bellow is a possble fix, diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 7a2c56fc..6591b71 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -391,20 +391,28 @@ static inline unsigned long mem_cgroup_protection(struct mem_cgroup *root, void mem_cgroup_calculate_protection(struct mem_cgroup *root, struct mem_cgroup *memcg); -static inline bool mem_cgroup_below_low(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_low(struct mem_cgroup *root, + struct mem_cgroup *memcg) { if (mem_cgroup_disabled()) return false; + if (root == memcg) + return false; + return READ_ONCE(memcg->memory.elow) >= page_counter_read(&memcg->memory); } -static inline bool mem_cgroup_below_min(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_min(struct mem_cgroup *root, + struct mem_cgroup *memcg) { if (mem_cgroup_disabled()) return false; + if (root == memcg) + return false; + return READ_ONCE(memcg->memory.emin) >= page_counter_read(&memcg->memory); } @@ -896,12 +904,14 @@ static inline void mem_cgroup_calculate_protection(struct mem_cgroup *root, { } -static inline bool mem_cgroup_below_low(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_low(struct mem_cgroup *root, + struct mem_cgroup *memcg) { return false; } -static inline bool mem_cgroup_below_min(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_min(struct mem_cgroup *root, + struct mem_cgroup *memcg) { return false; } diff --git a/mm/vmscan.c b/mm/vmscan.c index c71660e..fdcdd88 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2637,13 +2637,13 @@ static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc) mem_cgroup_calculate_protection(target_memcg, memcg); - if (mem_cgroup_below_min(memcg)) { + if (mem_cgroup_below_min(target_memcg, memcg)) { /* * Hard protection. * If there is no reclaimable memory, OOM. */ continue; - } else if (mem_cgroup_below_low(memcg)) { + } else if (mem_cgroup_below_low(target_memcg, memcg)) { /* * Soft protection. * Respect the protection only as long as > i386 test log shows mkfs -t ext4 pass > https://lkft.validation.linaro.org/scheduler/job/1443405#L1200 > > ref: > https://lore.kernel.org/linux-mm/cover.1588092152.git.chris@chrisdown.name/ > https://lore.kernel.org/linux-mm/CA+G9fYvzLm7n1BE7AJXd8_49fOgPgWWTiQ7sXkVre_zoERjQKg@mail.gmail.com/T/#t > > -- > Linaro LKFT > https://lkft.linaro.org -- Thanks Yafang 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.3 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,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 E2E69C433E4 for ; Thu, 21 May 2020 02:40:10 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B0F4F20758 for ; Thu, 21 May 2020 02:40:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="bI9s5ArB"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="CdhObMeC"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JIZNHQnm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0F4F20758 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1jbb7x-0004o1-EC; Thu, 21 May 2020 02:40:09 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jbb7w-0004nu-Pt for linux-f2fs-devel@lists.sourceforge.net; Thu, 21 May 2020 02:40:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Sender:Reply-To:Content-Transfer-Encoding :Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=/RCzazjPJQ1zcfvr5ivU8gZ2oW1vvouNHyaX2fPjs5o=; b=bI9s5ArBU2vz0wnqNOOBAY/LTE 4Nquaco7OlEO6F8XEaSOboxrmJVyH7VLMNXg6CAZxb6gff4Q+GoHXjuLvyRfnbiaTU5bSDaOWmGBc vE8SwfTS1DUd+6I63nU4HUpEdFsyIzkW7H7syW3LanLBfILzS5oHE8+YVycA5A8Rz5r4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/RCzazjPJQ1zcfvr5ivU8gZ2oW1vvouNHyaX2fPjs5o=; b=CdhObMeCVcQF+BIRWDPE0MHmVc LsiPGOosSl+cifz0N83l7n8TleLdg6fDj/tChvzXkyav9aZusYjDaDKPCkvbMwW0SBLFxtSJDYsNA 7aWQOUTxiAhvCBSO0VG7HPqSPfEqa+a0/v5htoRGJOgy8wpBB2AbqnsJ1VdYrUmn+sMA=; Received: from mail-il1-f193.google.com ([209.85.166.193]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.2) id 1jbb7u-00ABx6-W2 for linux-f2fs-devel@lists.sourceforge.net; Thu, 21 May 2020 02:40:08 +0000 Received: by mail-il1-f193.google.com with SMTP id l20so5511708ilj.10 for ; Wed, 20 May 2020 19:40:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/RCzazjPJQ1zcfvr5ivU8gZ2oW1vvouNHyaX2fPjs5o=; b=JIZNHQnmERaJeRhfnEjjac0W+vknvOwLXY/d6ercTVMilrrz524WChiYGwFGcaHgFJ K8JZk1i5INW6EyIXuYOyX2v32bfw6qRfgzQTQHHULRWMhQsYMBm89glhPbVBx2I6bwxs j20/Yum6NRQKLWYNIxFRjPx0QViHZTbPlmI1fZzO6exUlTKfLwEVLiDwpVb7Qfp6TgJ/ snhs+KlBeHyRitCTHyRBIFjZ454fFCb9qrYuro47/SQk4QgBQgus3sRPgPYvG8W/Vui1 AknW2UXV00QW+opr5rDKKkCPY+BNrd0MlLO7V3cFfkCwusagGNkXGNtRMJgA5pK9QeWA IAFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/RCzazjPJQ1zcfvr5ivU8gZ2oW1vvouNHyaX2fPjs5o=; b=JuofrUwDXsblVtqE17S4rH0sP1kchAWs9bCPYDadTwV61W5pnhL3fF4HfPrD6CfITh 1J1T2nVIIu43uNUZt3vYWGGdteUYHLnC8ag1Tr3vaP1adlAlzpZ2A7upRwJWtkECw6p6 kKLDwzhKPF7T9wO3NbanHIe0fxZMg0Xqz0wimKR5sf/LuZp4McrOHYI2qZ26u4br4ss/ QPvI3jzy3lWz8O6gU3IPCy75yvUrJkgqDtixOvapHcHHhiPc2e8EA5gvu2nToKZTHITU N97sDaqvELjlpL7VANrA41ebAJ2b4zKJA6/PDtQ83AREWjziOUVoSzSxR2hfAHxukeRg fKjA== X-Gm-Message-State: AOAM531Ueqglcc2XTarSRYJvvIzdTKed3w2GCZ9yG/xDspCYiwKzjqEU OBhmQm7MRg9iGadLwT3VATBOEnAwVtOGRJPKLCE= X-Google-Smtp-Source: ABdhPJyv/UYZjPy/DPwJRsYbSaKbImcwHJUxF5BT675dGaD56oiGCZioxLSjEnZKhN7916a+tUgfDxQbE7d+nnFanoQ= X-Received: by 2002:a92:9e11:: with SMTP id q17mr6952459ili.137.1590028801270; Wed, 20 May 2020 19:40:01 -0700 (PDT) MIME-Version: 1.0 References: <20200501135806.4eebf0b92f84ab60bba3e1e7@linux-foundation.org> <20200519075213.GF32497@dhcp22.suse.cz> <20200519084535.GG32497@dhcp22.suse.cz> In-Reply-To: From: Yafang Shao Date: Thu, 21 May 2020 10:39:25 +0800 Message-ID: To: Naresh Kamboju X-Headers-End: 1jbb7u-00ABx6-W2 Subject: Re: [f2fs-dev] mm: mkfs.ext4 invoked oom-killer on i386 - pagecache_get_page X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lkft-triage@lists.linaro.org, Michal Hocko , linux-mm , Andreas Dilger , Cgroups , Andrea Arcangeli , Anders Roxell , Hugh Dickins , Matthew Wilcox , Linux-Next Mailing List , linux-ext4 , Arnd Bergmann , linux-block , Jaegeuk Kim , Theodore Ts'o , Chris Down , open list , "Linux F2FS DEV, Mailing List" , Johannes Weiner , Andrew Morton , Roman Gushchin Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Thu, May 21, 2020 at 2:00 AM Naresh Kamboju wrote: > > On Wed, 20 May 2020 at 17:26, Naresh Kamboju wrote: > > > > > > This issue is specific on 32-bit architectures i386 and arm on linux-next tree. > > As per the test results history this problem started happening from > > Bad : next-20200430 > > Good : next-20200429 > > > > steps to reproduce: > > dd if=/dev/disk/by-id/ata-SanDisk_SSD_PLUS_120GB_190504A00573 > > of=/dev/null bs=1M count=2048 > > or > > mkfs -t ext4 /dev/disk/by-id/ata-SanDisk_SSD_PLUS_120GB_190804A00BE5 > > > > > > Problem: > > [ 38.802375] dd invoked oom-killer: gfp_mask=0x100cc0(GFP_USER), > > order=0, oom_score_adj=0 > > As a part of investigation on this issue LKFT teammate Anders Roxell > git bisected the problem and found bad commit(s) which caused this problem. > > The following two patches have been reverted on next-20200519 and retested the > reproducible steps and confirmed the test case mkfs -t ext4 got PASS. > ( invoked oom-killer is gone now) > > Revert "mm, memcg: avoid stale protection values when cgroup is above > protection" > This reverts commit 23a53e1c02006120f89383270d46cbd040a70bc6. > > Revert "mm, memcg: decouple e{low,min} state mutations from protection > checks" > This reverts commit 7b88906ab7399b58bb088c28befe50bcce076d82. > My guess is that we made the same mistake in commit "mm, memcg: decouple e{low,min} state mutations from protection checks" that it read a stale memcg protection in mem_cgroup_below_low() and mem_cgroup_below_min(). Bellow is a possble fix, diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 7a2c56fc..6591b71 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -391,20 +391,28 @@ static inline unsigned long mem_cgroup_protection(struct mem_cgroup *root, void mem_cgroup_calculate_protection(struct mem_cgroup *root, struct mem_cgroup *memcg); -static inline bool mem_cgroup_below_low(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_low(struct mem_cgroup *root, + struct mem_cgroup *memcg) { if (mem_cgroup_disabled()) return false; + if (root == memcg) + return false; + return READ_ONCE(memcg->memory.elow) >= page_counter_read(&memcg->memory); } -static inline bool mem_cgroup_below_min(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_min(struct mem_cgroup *root, + struct mem_cgroup *memcg) { if (mem_cgroup_disabled()) return false; + if (root == memcg) + return false; + return READ_ONCE(memcg->memory.emin) >= page_counter_read(&memcg->memory); } @@ -896,12 +904,14 @@ static inline void mem_cgroup_calculate_protection(struct mem_cgroup *root, { } -static inline bool mem_cgroup_below_low(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_low(struct mem_cgroup *root, + struct mem_cgroup *memcg) { return false; } -static inline bool mem_cgroup_below_min(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_min(struct mem_cgroup *root, + struct mem_cgroup *memcg) { return false; } diff --git a/mm/vmscan.c b/mm/vmscan.c index c71660e..fdcdd88 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2637,13 +2637,13 @@ static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc) mem_cgroup_calculate_protection(target_memcg, memcg); - if (mem_cgroup_below_min(memcg)) { + if (mem_cgroup_below_min(target_memcg, memcg)) { /* * Hard protection. * If there is no reclaimable memory, OOM. */ continue; - } else if (mem_cgroup_below_low(memcg)) { + } else if (mem_cgroup_below_low(target_memcg, memcg)) { /* * Soft protection. * Respect the protection only as long as > i386 test log shows mkfs -t ext4 pass > https://lkft.validation.linaro.org/scheduler/job/1443405#L1200 > > ref: > https://lore.kernel.org/linux-mm/cover.1588092152.git.chris@chrisdown.name/ > https://lore.kernel.org/linux-mm/CA+G9fYvzLm7n1BE7AJXd8_49fOgPgWWTiQ7sXkVre_zoERjQKg@mail.gmail.com/T/#t > > -- > Linaro LKFT > https://lkft.linaro.org -- Thanks Yafang _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yafang Shao Subject: Re: mm: mkfs.ext4 invoked oom-killer on i386 - pagecache_get_page Date: Thu, 21 May 2020 10:39:25 +0800 Message-ID: References: <20200501135806.4eebf0b92f84ab60bba3e1e7@linux-foundation.org> <20200519075213.GF32497@dhcp22.suse.cz> <20200519084535.GG32497@dhcp22.suse.cz> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/RCzazjPJQ1zcfvr5ivU8gZ2oW1vvouNHyaX2fPjs5o=; b=JIZNHQnmERaJeRhfnEjjac0W+vknvOwLXY/d6ercTVMilrrz524WChiYGwFGcaHgFJ K8JZk1i5INW6EyIXuYOyX2v32bfw6qRfgzQTQHHULRWMhQsYMBm89glhPbVBx2I6bwxs j20/Yum6NRQKLWYNIxFRjPx0QViHZTbPlmI1fZzO6exUlTKfLwEVLiDwpVb7Qfp6TgJ/ snhs+KlBeHyRitCTHyRBIFjZ454fFCb9qrYuro47/SQk4QgBQgus3sRPgPYvG8W/Vui1 AknW2UXV00QW+opr5rDKKkCPY+BNrd0MlLO7V3cFfkCwusagGNkXGNtRMJgA5pK9QeWA IAFQ== In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Naresh Kamboju Cc: Chris Down , Michal Hocko , Anders Roxell , "Linux F2FS DEV, Mailing List" , linux-ext4 , linux-block , Andrew Morton , open list , Linux-Next Mailing List , linux-mm , Arnd Bergmann , Andreas Dilger , Jaegeuk Kim , Theodore Ts'o , Chao Yu , Hugh Dickins , Andrea Arcangeli , Matthew Wilcox , Chao Yu , On Thu, May 21, 2020 at 2:00 AM Naresh Kamboju wrote: > > On Wed, 20 May 2020 at 17:26, Naresh Kamboju wrote: > > > > > > This issue is specific on 32-bit architectures i386 and arm on linux-next tree. > > As per the test results history this problem started happening from > > Bad : next-20200430 > > Good : next-20200429 > > > > steps to reproduce: > > dd if=/dev/disk/by-id/ata-SanDisk_SSD_PLUS_120GB_190504A00573 > > of=/dev/null bs=1M count=2048 > > or > > mkfs -t ext4 /dev/disk/by-id/ata-SanDisk_SSD_PLUS_120GB_190804A00BE5 > > > > > > Problem: > > [ 38.802375] dd invoked oom-killer: gfp_mask=0x100cc0(GFP_USER), > > order=0, oom_score_adj=0 > > As a part of investigation on this issue LKFT teammate Anders Roxell > git bisected the problem and found bad commit(s) which caused this problem. > > The following two patches have been reverted on next-20200519 and retested the > reproducible steps and confirmed the test case mkfs -t ext4 got PASS. > ( invoked oom-killer is gone now) > > Revert "mm, memcg: avoid stale protection values when cgroup is above > protection" > This reverts commit 23a53e1c02006120f89383270d46cbd040a70bc6. > > Revert "mm, memcg: decouple e{low,min} state mutations from protection > checks" > This reverts commit 7b88906ab7399b58bb088c28befe50bcce076d82. > My guess is that we made the same mistake in commit "mm, memcg: decouple e{low,min} state mutations from protection checks" that it read a stale memcg protection in mem_cgroup_below_low() and mem_cgroup_below_min(). Bellow is a possble fix, diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 7a2c56fc..6591b71 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -391,20 +391,28 @@ static inline unsigned long mem_cgroup_protection(struct mem_cgroup *root, void mem_cgroup_calculate_protection(struct mem_cgroup *root, struct mem_cgroup *memcg); -static inline bool mem_cgroup_below_low(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_low(struct mem_cgroup *root, + struct mem_cgroup *memcg) { if (mem_cgroup_disabled()) return false; + if (root == memcg) + return false; + return READ_ONCE(memcg->memory.elow) >= page_counter_read(&memcg->memory); } -static inline bool mem_cgroup_below_min(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_min(struct mem_cgroup *root, + struct mem_cgroup *memcg) { if (mem_cgroup_disabled()) return false; + if (root == memcg) + return false; + return READ_ONCE(memcg->memory.emin) >= page_counter_read(&memcg->memory); } @@ -896,12 +904,14 @@ static inline void mem_cgroup_calculate_protection(struct mem_cgroup *root, { } -static inline bool mem_cgroup_below_low(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_low(struct mem_cgroup *root, + struct mem_cgroup *memcg) { return false; } -static inline bool mem_cgroup_below_min(struct mem_cgroup *memcg) +static inline bool mem_cgroup_below_min(struct mem_cgroup *root, + struct mem_cgroup *memcg) { return false; } diff --git a/mm/vmscan.c b/mm/vmscan.c index c71660e..fdcdd88 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2637,13 +2637,13 @@ static void shrink_node_memcgs(pg_data_t *pgdat, struct scan_control *sc) mem_cgroup_calculate_protection(target_memcg, memcg); - if (mem_cgroup_below_min(memcg)) { + if (mem_cgroup_below_min(target_memcg, memcg)) { /* * Hard protection. * If there is no reclaimable memory, OOM. */ continue; - } else if (mem_cgroup_below_low(memcg)) { + } else if (mem_cgroup_below_low(target_memcg, memcg)) { /* * Soft protection. * Respect the protection only as long as > i386 test log shows mkfs -t ext4 pass > https://lkft.validation.linaro.org/scheduler/job/1443405#L1200 > > ref: > https://lore.kernel.org/linux-mm/cover.1588092152.git.chris@chrisdown.name/ > https://lore.kernel.org/linux-mm/CA+G9fYvzLm7n1BE7AJXd8_49fOgPgWWTiQ7sXkVre_zoERjQKg@mail.gmail.com/T/#t > > -- > Linaro LKFT > https://lkft.linaro.org -- Thanks Yafang