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=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL 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 772C7C433B4 for ; Wed, 21 Apr 2021 14:14:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFABB6144B for ; Wed, 21 Apr 2021 14:13:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFABB6144B Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2C62D6B0072; Wed, 21 Apr 2021 10:13:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 276A86B0073; Wed, 21 Apr 2021 10:13:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 13EFF6B0074; Wed, 21 Apr 2021 10:13:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0132.hostedemail.com [216.40.44.132]) by kanga.kvack.org (Postfix) with ESMTP id EF51E6B0072 for ; Wed, 21 Apr 2021 10:13:58 -0400 (EDT) Received: from smtpin33.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A1B1218034F55 for ; Wed, 21 Apr 2021 14:13:58 +0000 (UTC) X-FDA: 78056568156.33.FFA5D88 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by imf20.hostedemail.com (Postfix) with ESMTP id 0B34EE4 for ; Wed, 21 Apr 2021 14:13:50 +0000 (UTC) Received: by mail-lf1-f54.google.com with SMTP id h36so12914643lfv.7 for ; Wed, 21 Apr 2021 07:13:58 -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=KT5Z/sPJXf0qDYy55bMraiO4nEL20VpFAQ+FPYD2/dw=; b=WFAWOqMmzOQnQNVjpAKoR6YqWuxUDxMFdKgszw7Kn8uz7r8hz4pWSNkrWd5wNrvPGp q39wDsrIdJmGWqrYNH8EUO6pO+DVhIsP8AaaNicOjCkRz1CNsoCn+ETNeFl3Q8hL00Ct CI1EzrSnzpp4EWE1LXyyb2yFXfBfV/RmqRZCM6pQdzS7WbVf46BwNckO0u6hNrXyZKcf 0nxRN8JIvGm8b0shRuwYStgnyt9mEE0rBE+HLxDOYWOElrfF7Tk4/ZSmZiS4411A4+bU 38t+fVT8D6CfEj3lIXI40eG7FQCx5Bzpg1adr0Ij4D6cG3oMI17mt+20w8Tl4tniDdvW Xiag== 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=KT5Z/sPJXf0qDYy55bMraiO4nEL20VpFAQ+FPYD2/dw=; b=NqoY+lVs2ZnGQqUzIu0AMK7nJ7XWkRnjQB5go1FFyJ9ad4tPEC5l0FU7DlVLRfNm5F RlFgKvdObLUH5MnmkOhoPpQQ8kCk+TpktdxmHhDxW5ukJXYJ8my3Hd2lbPd4bZWacdML /DMjEySLS98zHgtwrfloGdi/iCXa5UPRpb15uJHzDSi/WIxEyxTa5rl4NBINteAUpzcY 1Lw/d5xTE2+oU9kAuyKV3AOH6WD60E0JTjcwbhl02xebbqnzQn264QbuWhXTZ+syzM1h ySEJMGqjS3C6qymty2FqtkjS+MwmKh7WgFzwIlpIrBbhKu3kiXk9N7+KLG9x+EW8iG/Q yAZQ== X-Gm-Message-State: AOAM531gEpHC86Wa7tboSQF5UOZiYOKm/grGj5GVoFdB9g+Hvz8Xsv3G t+AQQoSxA+wqTX6oj9tD1orNTavL8AitgWi4/jG7kw== X-Google-Smtp-Source: ABdhPJwKfxnLC0EMvkKJWK7JOfls96yUQHQql2a1N5hFMm4auIb20AtzZv8tv5ao9CXlQJFzRhkSNO40dAKrV1P9OBM= X-Received: by 2002:a05:6512:2037:: with SMTP id s23mr19348557lfs.358.1619014436354; Wed, 21 Apr 2021 07:13:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Shakeel Butt Date: Wed, 21 Apr 2021 07:13:45 -0700 Message-ID: Subject: Re: [RFC] memory reserve for userspace oom-killer To: Michal Hocko Cc: Roman Gushchin , Johannes Weiner , Linux MM , Andrew Morton , Cgroups , David Rientjes , LKML , Suren Baghdasaryan , Greg Thelen , Dragos Sbirlea , Priya Duraisamy Content-Type: text/plain; charset="UTF-8" X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0B34EE4 X-Stat-Signature: 7eitkw6k4558uzybb1s71g5yi4bnjudz Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf20; identity=mailfrom; envelope-from=""; helo=mail-lf1-f54.google.com; client-ip=209.85.167.54 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619014430-590482 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 Wed, Apr 21, 2021 at 12:23 AM Michal Hocko wrote: > [...] > > In our observation the global reclaim is very non-deterministic at the > > tail and dramatically impacts the reliability of the system. We are > > looking for a solution which is independent of the global reclaim. > > I believe it is worth purusing a solution that would make the memory > reclaim more predictable. I have seen direct reclaim memory throttling > in the past. For some reason which I haven't tried to examine this has > become less of a problem with newer kernels. Maybe the memory access > patterns have changed or those problems got replaced by other issues but > an excessive throttling is definitely something that we want to address > rather than work around by some user visible APIs. > I agree we want to address the excessive throttling but for everyone on the machine and most importantly it is a moving target. The reclaim code continues to evolve and in addition it has callbacks to diverse sets of subsystems. The user visible APIs is for one specific use-case i.e. oom-killer which will indirectly help in reducing the excessive throttling. [...] > > So, the suggestion is to have a per-task flag to (1) indicate to not > > throttle and (2) fail allocations easily on significant memory > > pressure. > > > > For (1), the challenge I see is that there are a lot of places in the > > reclaim code paths where a task can get throttled. There are > > filesystems that block/throttle in slab shrinking. Any process can get > > blocked on an unrelated page or inode writeback within reclaim. > > > > For (2), I am not sure how to deterministically define "significant > > memory pressure". One idea is to follow the __GFP_NORETRY semantics > > and along with (1) the userspace oom-killer will see ENOMEM more > > reliably than stucking in the reclaim. > > Some of the interfaces (e.g. seq_file uses GFP_KERNEL reclaim strength) > could be more relaxed and rather fail than OOM kill but wouldn't your > OOM handler be effectivelly dysfunctional when not able to collect data > to make a decision? > Yes it would be. Roman is suggesting to have a precomputed kill-list (pidfds ready to send SIGKILL) and whenever oom-killer gets ENOMEM, it would go with the kill-list. Though we are still contemplating the ways and side-effects of preferably returning ENOMEM in slowpath for oom-killer and in addition the complexity to maintain the kill-list and keeping it up to date. thanks, Shakeel