Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp25226pxy; Tue, 4 May 2021 17:40:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGcCO04f8121K3RHYRh59Cz88Wr1epS89HT2cJ4Jw0DLZAtFoh0p0XDYOWgw3Tpx0G5XFY X-Received: by 2002:a05:6402:7c7:: with SMTP id u7mr15671123edy.2.1620175224494; Tue, 04 May 2021 17:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620175224; cv=none; d=google.com; s=arc-20160816; b=MYZ2KOAJvIeRlCS5wTwgrHN1P4LJLA1L2OfY1MxW8ITzT+8wYc6BSB+BtNdLjMscxT 2qmNRwOdoBEI7qvsIaJ6jskww1z383kKNWLp5rWRw+UPs3InfPTXrCJmV/ADJXuZ3vhu 4LyaDayeqo6Oo6Sq0MzEwulil4ijBHXtIi9X8hc22clUptdCOHPObukG7YhxrTWOWs1H UpbYlM8zlQWOMKjBzvmYALAjB7eMOTwpUgy9fTcyzMQG8y6yemuWxtrjGqhRtdwQXoCT +aYpEz6loReWPz2voTvWU4py2UJq/iLAdimStZw9wNnyMRvzahLikhgoNYWS6y2PjGyH /ByA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rE+67pf/2itGCrXRDqOt78tityf8/56CzXmtqalTs7Y=; b=mQ7R6Alz5yjm1WdYmEuopzDTj8UJr+zBPnMNfnaCBmasfRU2GI6IOgmAVUeo/4GNKs bPoLFwEgglee+Tt2yLqR/hpDAT0aEBpYIAY6bYJTxPgUMCCgOAd+UcalaajD9zPfxoRZ r9B7/5zdG4+wU7zB7rWMRHmi9y06EAM91xS5zyPokafxXRmvPC/veIu7qy2gDWQ44vX7 5q1Z50lWsax7vv44zKjc/EKuEtotHDyqMmdXvfBQJPokke2DhoUGZOPvdd/5b3rdX/Ww 6bHcUmIvgcr/kVvyq0oW7fow2STx97MZenp8ntZbI7qGNK+BFeDphVBcAZYhKLIjPR0G 7rdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oPjqJycd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j7si3907212ejn.636.2021.05.04.17.40.01; Tue, 04 May 2021 17:40:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oPjqJycd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231542AbhEEAil (ORCPT + 99 others); Tue, 4 May 2021 20:38:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230328AbhEEAil (ORCPT ); Tue, 4 May 2021 20:38:41 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89D78C06174A for ; Tue, 4 May 2021 17:37:45 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id 2so121211lft.4 for ; Tue, 04 May 2021 17:37:45 -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=rE+67pf/2itGCrXRDqOt78tityf8/56CzXmtqalTs7Y=; b=oPjqJycdh906u/NKD96OF/32I8GkIKXWJvImxBVe8Uoi5eQH0eCxEmU1C14OFp77Bh 7Q0cLGd/hOMzojqrDn4N+h/krRVmuvkI/846O1BZJG6acacCSK6qRvH8kWCAw0IgRM2o tW70LTDJPlXiFxn+Onp+XUen2V3IVkqMFUZ7B20neSLbTJyPlWuIJLgM+YpmiPQ3zIUA kc8idKtZ5R86Yp4837IQvSnAO/r8OkY3shl3v0ueAglTxveiZ600ewUj216ssOQDZoWi COcs6/4gvKgeap02wOQj5e0w7c0XRY4BL7JWx7btEdKvqUOorT11BgEN8oY2OwmENhV1 yMtA== 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=rE+67pf/2itGCrXRDqOt78tityf8/56CzXmtqalTs7Y=; b=Awr/TK2UueS4x61M5XPJs2u6CfBV0Gr85Y8QIiofFYZ2z211E0UCiVSgzs+6FkZmcF BdrTfaDw1NWkTvvYFBAhN25RLA1BedoapGavMXigTstZYu4iBtIDeNnzWAETUJ2buBX8 eUuGBxpnE5oC1wWdt5g4g5YbcDkblTkXtlQhH3sjgfyn5ZfIMaDy5HePQkGyPZ1IiWBL D2mZtDh14DPtlBxNEnDIRVXp8ynVgwXtx31tuU1kRfBGZxXsoulFkZNtzsJuYLgSgFi2 LjwlPcdpihOOoqWZmEAUJpy/ZSOztbA1ekFFmvy20BJxP5rF1xHXhIEHQA0HMx/aS0DD peOw== X-Gm-Message-State: AOAM530OxtM4jjvP3AnpdcqmhXnkX3UyeXGq9ScOpSQCPadHUZX8c8Uq KLHAzBLhLpJTOuobYp6vIp9gliNVzxlTamwUB++8qw== X-Received: by 2002:a05:6512:208b:: with SMTP id t11mr16611191lfr.358.1620175063595; Tue, 04 May 2021 17:37:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Shakeel Butt Date: Tue, 4 May 2021 17:37:32 -0700 Message-ID: Subject: Re: [RFC] memory reserve for userspace oom-killer To: Michal Hocko Cc: Johannes Weiner , Roman Gushchin , Linux MM , Andrew Morton , Cgroups , David Rientjes , LKML , Suren Baghdasaryan , Greg Thelen , Dragos Sbirlea , Priya Duraisamy Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 21, 2021 at 7:29 AM Michal Hocko wrote: > [...] > > > What if the pool is depleted? > > > > This would mean that either the estimate of mempool size is bad or > > oom-killer is buggy and leaking memory. > > > > I am open to any design directions for mempool or some other way where > > we can provide a notion of memory guarantee to oom-killer. > > OK, thanks for clarification. There will certainly be hard problems to > sort out[1] but the overall idea makes sense to me and it sounds like a > much better approach than a OOM specific solution. > > > [1] - how the pool is going to be replenished without hitting all > potential reclaim problems (thus dependencies on other all tasks > directly/indirectly) yet to not rely on any background workers to do > that on the task behalf without a proper accounting etc... > -- I am currently contemplating between two paths here: First, the mempool, exposed through either prctl or a new syscall. Users would need to trace their userspace oom-killer (or whatever their use case is) to find an appropriate mempool size they would need and periodically refill the mempools if allowed by the state of the machine. The challenge here is to find a good value for the mempool size and coordinating the refilling of mempools. Second is a mix of Roman and Peter's suggestions but much more simplified. A very simple watchdog with a kill-list of processes and if userspace didn't pet the watchdog within a specified time, it will kill all the processes in the kill-list. The challenge here is to maintain/update the kill-list. I would prefer the direction which oomd and lmkd are open to adopt. Any suggestions?