Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp522622pxy; Thu, 22 Apr 2021 07:30:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwIlT8Je37gciiuZotgMRCLWTZDzfxUKVuxDbx5WLbWDsaNRsN+sioMBzngFCh3HufPgrcA X-Received: by 2002:a17:907:e8a:: with SMTP id ho10mr3718802ejc.110.1619101838934; Thu, 22 Apr 2021 07:30:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619101838; cv=none; d=google.com; s=arc-20160816; b=U5ENIbUCWKZZ2g7NT8P3rXdtZdZhk21DwmgRuHYNC9BEmc52pY3pNlO2/H6T6W77E+ 7yv2AY8g3JETyTUhkl8IWxLaY7dgonoEX8UAYb+OyYx/oufII9FM73JrWqEVmoic0bWp K7VNL3uHizjKQLBBpjfraSfXHg0zaovgXoCV4uDJuoJ4tMD1UMWlpD0vLBtGlhZFV9mS MkD1aQXPEfMqfiWDTDsESGdINTgV15uljB7IGyNhm79cB24gstYVvTAC5mxS7/mXSYPk Ed2aEABb2l7AQ+cUkPFWnOhvo5ZC4NuBAXgzRBfthIyUGrHwqEc90yjSfwYhjh3NTkkD T0ig== 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=YUbZYT4OBaB64X7LHgzjKFjOfvV90LK9Vn0x4eZD4WE=; b=LzDnbHVvVIkO1y+lLzkHELBhzZ+2CNA38M9a+dsFmBHSttnfSqRIJ+Ph8+La4JHQDL qqddKBAwrICmIM/9HqJeyI5aWe3gtv+mJKveQa2nZKOFVKvDBPAYbms6ghX4vLySw8ER PW3dtcEGGUBeWO4a74wDwae6RwzR/3RRaNKezus+Spq6l34oOLfuk0eGvR7qTJf4Mh+c Ymb5MvFjVQJJEMoO+XPoR+wecJ+VsCrD2K1iMLntccLSoiAFHgvLCff+KP6NLBBmZ/7p 4U8ahRXMeMlSgjZdbRy/s62vaAOBEpO2xPxYNoZ7ADceWcXWJmIJdAxxuBzSn6hz6mbL fjVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=m03NQBJs; 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 bd8si2307398edb.453.2021.04.22.07.30.14; Thu, 22 Apr 2021 07:30:38 -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=m03NQBJs; 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 S236465AbhDVO1y (ORCPT + 99 others); Thu, 22 Apr 2021 10:27:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236398AbhDVO1x (ORCPT ); Thu, 22 Apr 2021 10:27:53 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3A7A2C06174A for ; Thu, 22 Apr 2021 07:27:17 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id a5so15097911ljk.0 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=NX6U6FjZXGFgLOyEXSlM5tonxvPqr9WZwjlVLOHNNLVv0HwMyiW5TUcJA4FQDt1WBx 3CLMufnRY5l6OEEprbF5f0OlXjvkpMl5bMZ7KNhSCo3y3H0QCQ1SewYErbTiSJqBMJX+ uYHVOzDcEtfdzyNCeJ/IZOtvGiqOpYXqqLLJixhqa6RNs3rR1zjIgsFD46mbk7Zadccs UJj9zSMzO9mXZG1msKbbkzpgg87DkvynHoAqeQV1Pakmyf8EQqksLLJ4RciQ6IrTFA/D Zqy6Jc5G59LxsVk0ghXlkqPp9tBNEWKahGiXAwmAeC3MZ0/diKsZSVCJOCMnL+w0sMQc BcgA== X-Gm-Message-State: AOAM532RbEHrCTy94vnNVkUmfPeVU7iD4FXEf7+HwXwmEtYai/NKL4Mk fQ4lshSTT4zkNV6ANAPI2dOC8NhpDD3J8sViL2xp6A== 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" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.