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,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 6D868C433ED for ; Thu, 22 Apr 2021 14:27:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D8F106142F for ; Thu, 22 Apr 2021 14:27:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D8F106142F 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 31CCC6B006C; Thu, 22 Apr 2021 10:27:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2A4846B006E; Thu, 22 Apr 2021 10:27:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F7686B0070; Thu, 22 Apr 2021 10:27:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id E25806B006C for ; Thu, 22 Apr 2021 10:27:17 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id A1AA5824805A for ; Thu, 22 Apr 2021 14:27:17 +0000 (UTC) X-FDA: 78060230514.04.B3AC348 Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) by imf28.hostedemail.com (Postfix) with ESMTP id 918A62000267 for ; Thu, 22 Apr 2021 14:27:19 +0000 (UTC) Received: by mail-lj1-f170.google.com with SMTP id l22so44713528ljc.9 for ; Thu, 22 Apr 2021 07:27:17 -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=YUbZYT4OBaB64X7LHgzjKFjOfvV90LK9Vn0x4eZD4WE=; b=m03NQBJsiIYmZLHNAhp0ZNgR6JE1hvKR6rXrXKgEbpcm/xxcVWpyWKSe4UJSSFoEA0 6VERSKMt3H1owy6VkbUcLEpYa4p+4xzIUeG0QGSkO/4n+f5U0hQJcuEKfVa7RGzmuZDc gs1Qs8aNheTNoYmGGp+2vAbMg2xCCtRdzRMSlQaC5Fo28MNBGDgSyPMkwk6copXCONZy gohJAjVusy8MudtqtIcM1D/lHeYMhSVwV6qeQtp/AircejjDw5yUBk08fU3A2mZyrMX8 LEUxOeNIb2m0yU9EvunJ87XnZGy56PrEY71VEgmDdl12YHu9jtL4MBtBenFNr+/I+XRy ev5w== 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=YUbZYT4OBaB64X7LHgzjKFjOfvV90LK9Vn0x4eZD4WE=; b=SRazFFRQwxE5xv3PaiKXtPKHHATZD+d5SeSOJZ98JbCdEvodYlQCS7TnooKqOV4CK+ NzEzNPifnT/V6uay3NcguJ/5pr1qEjT1UbZudUHUmgxGzOYJiYzM+Uc+2XuS/0fbUmmD yb/wrcKYGobjoLzh0S41m/9/H8IYrEjFRyQsuMBHCoEQFWAxeX6Ao8RkCc+NMc6rt3Yt GEHnG3zmEgE+ErWJyLKrYbfIfH9u2oy1wmjle9I0QCBVaR2NQMvfuub6n/JofBIZPx6X piKpvuxMTres2zoRNL6K2dbh1WMACLKe+gnr65jpXEUiq8y9QI/9n+xQQDlxwxYJgYgg 8oFQ== X-Gm-Message-State: AOAM531zJM6UtAgZFkIhdC+TWQ0lGH6Wwb1r13E9KQDmP4JqcGqhBDgR IScDIBvZ/Goy1HOqbuCMZaD0boyLQ5/hQMd1i+iwYw== X-Google-Smtp-Source: ABdhPJxuPeU6YJj81GeUryMLJyMPTds2wqBiSmhpJSyCNeXFkuQsmGAZagAn1Y0AMi6ejQI0rH+KkH3+1wSZAPT7DXw= X-Received: by 2002:a2e:9cc1:: with SMTP id g1mr2742525ljj.0.1619101635457; Thu, 22 Apr 2021 07:27:15 -0700 (PDT) MIME-Version: 1.0 References: <699e51ba-825d-b243-8205-4d8cff478a66@sony.com> <1f8d300b-9a8b-de09-6d5d-6a9c20c66d24@sony.com> <6eaa4c24-c565-bc5d-dbca-b73c72569a16@sony.com> In-Reply-To: <6eaa4c24-c565-bc5d-dbca-b73c72569a16@sony.com> From: Shakeel Butt Date: Thu, 22 Apr 2021 07:27:04 -0700 Message-ID: Subject: Re: [RFC] memory reserve for userspace oom-killer To: peter enderborg Cc: Johannes Weiner , Roman Gushchin , Michal Hocko , 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: rspam01 X-Rspamd-Queue-Id: 918A62000267 X-Stat-Signature: z7yt3qqe1xp6bxok4tsy8y4zfwx17ujb Received-SPF: none (google.com>: No applicable sender policy available) receiver=imf28; identity=mailfrom; envelope-from=""; helo=mail-lj1-f170.google.com; client-ip=209.85.208.170 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1619101639-199122 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 10:39 PM wrote: > > On 4/21/21 9:18 PM, Shakeel Butt wrote: > > On Wed, Apr 21, 2021 at 11:46 AM wrote: > >> On 4/21/21 8:28 PM, Shakeel Butt wrote: > >>> On Wed, Apr 21, 2021 at 10:06 AM peter enderborg > >>> wrote: > >>>> On 4/20/21 3:44 AM, Shakeel Butt wrote: > >>> [...] > >>>> I think this is the wrong way to go. > >>> Which one? Are you talking about the kernel one? We already talked out > >>> of that. To decide to OOM, we need to look at a very diverse set of > >>> metrics and it seems like that would be very hard to do flexibly > >>> inside the kernel. > >> You dont need to decide to oom, but when oom occurs you > >> can take a proper action. > > No, we want the flexibility to decide when to oom-kill. Kernel is very > > conservative in triggering the oom-kill. > > It wont do it for you. We use this code to solve that: Sorry what do you mean by "It wont do it for you"? [...] > int __init lowmemorykiller_register_oom_notifier(void) > { > register_oom_notifier(&lowmemorykiller_oom_nb); This code is using oom_notify_list. That is only called when the kernel has already decided to go for the oom-kill. My point was the kernel is very conservative in deciding to trigger the oom-kill and the applications can suffer for long. We already have solutions for this issue in the form of userspace oom-killers (Android's lmkd and Facebook's oomd) which monitors a diverse set of metrics to early detect the application suffering and trigger SIGKILLs to release the memory pressure on the system. BTW with the userspace oom-killers, we would like to avoid the kernel oom-killer and memory.swap.high has been introduced in the kernel for that purpose.