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=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=ham 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 C08CEC4338F for ; Tue, 17 Aug 2021 19:10:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 367C460BD3 for ; Tue, 17 Aug 2021 19:10:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 367C460BD3 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9C5066B0071; Tue, 17 Aug 2021 15:10:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 975378D0002; Tue, 17 Aug 2021 15:10:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 863E98D0001; Tue, 17 Aug 2021 15:10:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0146.hostedemail.com [216.40.44.146]) by kanga.kvack.org (Postfix) with ESMTP id 6CB816B0071 for ; Tue, 17 Aug 2021 15:10:30 -0400 (EDT) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 0F1B124897 for ; Tue, 17 Aug 2021 19:10:30 +0000 (UTC) X-FDA: 78485513820.05.9403EFF Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by imf24.hostedemail.com (Postfix) with ESMTP id BED68B00083E for ; Tue, 17 Aug 2021 19:10:29 +0000 (UTC) Received: by mail-lj1-f175.google.com with SMTP id y7so515125ljp.3 for ; Tue, 17 Aug 2021 12:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Iykb3zVshE4eA6E5ehs/j8Ti0hcMXuAQMSGt4bHNST4=; b=P6s2laW+/ySM+LSMlI6J0A+C6LGd7jgwKCV5z/iMsS7y6l+jLs8+qjEGr/Z8ax6QAh Wix/NJ09rEJYwkRlnEQ+HCSlhqX/1kNgInBda0vwE049aVDpPX/8tEaleWsaQKdJ8KbA VSQeo28B0Ab1hdE0RFxEDc8eOLFlglPnYgmTK8leE5Hd5NFyDmA9erUHNxlRsL58gOze KlDAzXxaeRvelYps59sacVX3uaz5Ads0lKSaa6TG79Bmf8j3Wv+b+idvwDEnBKpGvuPA 8H4XQBuneBsrBm16zIePSYHCISi3yewlxpltvPc6d/1ywkkYxH6EmN63h5wt8BE5LRAr gi8g== 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=Iykb3zVshE4eA6E5ehs/j8Ti0hcMXuAQMSGt4bHNST4=; b=BShIy9wHzzIEg8vzGugOuqmsegE6/+J8mu/zt+O4ZRwYJoiTq3PXMOfnk9rY9pUUG+ qR6iROJGApkL9fCBGKhjeHvyQD+ZS/oOPjz1lY87BTkAeoXJFJMLQF06RUEF2l71m5RY 6PT68fLw/TLIo0Et/ZMTOnWGhXM5v7thMTerb7Yorwo+SGj9Qs0xwMjlLcjMR9rOftKH PxorUaS87nSU2/dmzExYp9pN2/TRqvL7ZjUm6/F7qaqbSqFGGTdCbL5A5B167dsUBEU4 4Ynt8ZCfIpKiSDhj1C0zLJdEndjhrSkrkicmG/RLzyIIEf8ydiljJnPEzs3kVEKIZbBQ pAqQ== X-Gm-Message-State: AOAM530NPqmP32LKXt90kAZLYN4V/xRHCyOxtp9L9B2LPPRJ/h0ze92W x9Hu98Vuq9hpi4Ng67tYRTP3+chTDJd7d1WwYiDedQ== X-Google-Smtp-Source: ABdhPJyNgt4XbUwgdloQdNksckqOArZjCflImGwdW9tidae85j9iEPkeav+6SjVzRCSzNylk7r+ETTaOZNd1uNM9ZE8= X-Received: by 2002:a05:651c:1248:: with SMTP id h8mr2590013ljh.160.1629227427941; Tue, 17 Aug 2021 12:10:27 -0700 (PDT) MIME-Version: 1.0 References: <20210817180506.220056-1-hannes@cmpxchg.org> In-Reply-To: <20210817180506.220056-1-hannes@cmpxchg.org> From: Shakeel Butt Date: Tue, 17 Aug 2021 12:10:16 -0700 Message-ID: Subject: Re: [PATCH] mm: memcontrol: fix occasional OOMs due to proportional memory.low reclaim To: Johannes Weiner Cc: Andrew Morton , Leon Yang , Chris Down , Roman Gushchin , Michal Hocko , Linux MM , Cgroups , LKML , Kernel Team Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: BED68B00083E Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=P6s2laW+; spf=pass (imf24.hostedemail.com: domain of shakeelb@google.com designates 209.85.208.175 as permitted sender) smtp.mailfrom=shakeelb@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam01 X-Stat-Signature: wo5dtr98ohiupoxgfnn61t8fpanwxh1b X-HE-Tag: 1629227429-269673 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 Tue, Aug 17, 2021 at 11:03 AM Johannes Weiner wrote: > > We've noticed occasional OOM killing when memory.low settings are in > effect for cgroups. This is unexpected and undesirable as memory.low > is supposed to express non-OOMing memory priorities between cgroups. > > The reason for this is proportional memory.low reclaim. When cgroups > are below their memory.low threshold, reclaim passes them over in the > first round, and then retries if it couldn't find pages anywhere else. > But when cgroups are slighly above their memory.low setting, page scan *slightly > force is scaled down and diminished in proportion to the overage, to > the point where it can cause reclaim to fail as well - only in that > case we currently don't retry, and instead trigger OOM. > > To fix this, hook proportional reclaim into the same retry logic we > have in place for when cgroups are skipped entirely. This way if > reclaim fails and some cgroups were scanned with dimished pressure, *diminished > we'll try another full-force cycle before giving up and OOMing. > > Reported-by: Leon Yang > Signed-off-by: Johannes Weiner Should this be considered for stable? Reviewed-by: Shakeel Butt [...] > > static inline void mem_cgroup_calculate_protection(struct mem_cgroup *root, > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 4620df62f0ff..701106e1829c 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -100,9 +100,12 @@ struct scan_control { > unsigned int may_swap:1; > > /* > - * Cgroups are not reclaimed below their configured memory.low, > - * unless we threaten to OOM. If any cgroups are skipped due to > - * memory.low and nothing was reclaimed, go back for memory.low. > + * Cgroup memory below memory.low is protected as long as we > + * don't threaten to OOM. If any cgroup is reclaimed at > + * reduced force or passed over entirely due to its memory.low > + * setting (memcg_low_skipped), and nothing is reclaimed as a > + * result, then go back back for one more cycle that reclaims *back