Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2130132imc; Tue, 12 Mar 2019 07:38:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzrtrnc/EIMUHADx1WGvuBOjkLeEYvKNH3lkOqH6jS7xUL5wK0wm22fzU6RozYziYJMEOki X-Received: by 2002:a17:902:2702:: with SMTP id c2mr39793624plb.239.1552401501914; Tue, 12 Mar 2019 07:38:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552401501; cv=none; d=google.com; s=arc-20160816; b=JXmQtTbvsbx/fiNwgIUZJJ1dToM06uDL3kjO63z6+iLCdLlSGzEH30YxuXC8j+/QgD qu+8lKMWEDtzVmAJurPMGf1Fm/mqasp/XwSKGtyS7vmxshlHTqGuQfmOdpEigHgWof+x jAzd1bz7+Nsh/YSfCM4tQuIFydRBsOpwhyisCMtV9fsFTciwZ/7Z2ccvTKciAtgQaoFO UTfmNRtTvCN1oWcPAs57aO1jnyGKltvmeUQCm9u0K4CzGjzRm14rH2AI62ayG2nDQeGf bMAZOA4UEbCRfEgMc+1tNB5A99btOJ5px40NInDGujF19GqtgnpzLKVPhKHx8e87atC5 WDmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=iRTF81XNeQwjJa5bhQu6Xf+1EuYh+2bPe7EUzUpU52g=; b=dyA1HegyS1mb45mUvb/4pmxcZs9DyBAOVodJbNmHiFvQuhyHei+j9nxiv5kzPgBwhU VE9zXYIxrJM6e0Z4hnS/GXnUak9qNoD6J1mD0nA7fooBthDMc0hGBmWDVCUDu45frTnt T3OTZvbUn/FuREk8C4TR0YnHA0B1mq9beW6KHfclfok62DLuUBMs6KlZiZqKsOdyYS1d bDAnjjJKe6ji2G/O2GvNjXiTWyUau28ysiHkmoFKoYgl0Yo08/YpvYYMUF39szUJamDw fLEB/2Og5DGBHh1FRDzf2UqD46I79eRxTT6g/82c+bi+XufZQt6krphMv05HHZMDcaQM Z27g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="ay/7cip6"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id d23si8261915plr.333.2019.03.12.07.38.06; Tue, 12 Mar 2019 07:38:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="ay/7cip6"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726630AbfCLOhM (ORCPT + 99 others); Tue, 12 Mar 2019 10:37:12 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44677 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726385AbfCLOhM (ORCPT ); Tue, 12 Mar 2019 10:37:12 -0400 Received: by mail-wr1-f66.google.com with SMTP id w2so2950965wrt.11 for ; Tue, 12 Mar 2019 07:37:11 -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=iRTF81XNeQwjJa5bhQu6Xf+1EuYh+2bPe7EUzUpU52g=; b=ay/7cip6wu0tI10WzvwNE1MQAcjNhmixLZczxHyaG4Qkg8wYfW/JogftocehntIDSj 5Nm/JJP8ToZSt/XDPlYpoKnUhKdQ1n+dgSgTwQj0/x/q00TtdQWBtcUtT6aQsMzL9eqC Eg1mR97fXDxSdWAQQ7FCiaO+Eg/+tiyrdClDdShzvVbTlyNwQLnA5Ko97ineMWhykWGZ TzuYE0yAB/K/v8t7Yaog6VeB5o4taXmzw1DOR44DsgcLuvz4OnmXa8zgEzq544B0B/ww oTIr01rd8och48LGaqWz+QImRZrRRQ1IauwVECxswlnjwuaKQNaUohZJzW2zNVqg8PKX eYQw== 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=iRTF81XNeQwjJa5bhQu6Xf+1EuYh+2bPe7EUzUpU52g=; b=uSdRGJMeIz+hGfxkh6g4Rl6IL6YlX0vXvPb+Q6Z3dD5PzP8j6O5duuNXMHcIh5Odzk 6+NQE82mjflmKvcUfOGIXkJXO1ZQywssj1oKneqRCvrhGMwAl0rxaGev0aZS7TDt3z/B EVs1yNlaL1LurF6oaJklZTlJ6Nll+t3eGrsmuZaIwO+urkCUx66mTxSmVYNl8k7T3TYD Zhe1+dh/qvKTkLWpYihrYmYkcM4AleUzcvMTskTz0tg2vzo+GvtLPqyuNjphCgIsq7uS bqpOJ8/Q5pTi3UoEpqxr9Ol+exOeD6bmG39FepHjQb+IQOJ9ghzQd7Blty/iee0zimHH 06MA== X-Gm-Message-State: APjAAAVWIvxSw6FrkE1miV0vXpr9+aJIMuJoYxgum5jkvq+htg9YsSPP GX9WEZcgfJhIvDXoIC69zSqDHyGqx+KElD8qnQkuWQ== X-Received: by 2002:a5d:40c5:: with SMTP id b5mr24653747wrq.107.1552401430345; Tue, 12 Mar 2019 07:37:10 -0700 (PDT) MIME-Version: 1.0 References: <20190310203403.27915-1-sultan@kerneltoast.com> <20190311174320.GC5721@dhcp22.suse.cz> <20190311175800.GA5522@sultan-box.localdomain> <20190311204626.GA3119@sultan-box.localdomain> <20190312080532.GE5721@dhcp22.suse.cz> In-Reply-To: <20190312080532.GE5721@dhcp22.suse.cz> From: Suren Baghdasaryan Date: Tue, 12 Mar 2019 07:36:58 -0700 Message-ID: Subject: Re: [RFC] simple_lmk: Introduce Simple Low Memory Killer for Android To: Michal Hocko Cc: Sultan Alsawaf , Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Ingo Molnar , Peter Zijlstra , LKML , devel@driverdev.osuosl.org, linux-mm , Tim Murray Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 12, 2019 at 1:05 AM Michal Hocko wrote: > > On Mon 11-03-19 15:15:35, Suren Baghdasaryan wrote: > > On Mon, Mar 11, 2019 at 1:46 PM Sultan Alsawaf wrote: > > > > > > On Mon, Mar 11, 2019 at 01:10:36PM -0700, Suren Baghdasaryan wrote: > > > > The idea seems interesting although I need to think about this a bit > > > > more. Killing processes based on failed page allocation might backfire > > > > during transient spikes in memory usage. > > > > > > This issue could be alleviated if tasks could be killed and have their pages > > > reaped faster. Currently, Linux takes a _very_ long time to free a task's memory > > > after an initial privileged SIGKILL is sent to a task, even with the task's > > > priority being set to the highest possible (so unwanted scheduler preemption > > > starving dying tasks of CPU time is not the issue at play here). I've > > > frequently measured the difference in time between when a SIGKILL is sent for a > > > task and when free_task() is called for that task to be hundreds of > > > milliseconds, which is incredibly long. AFAIK, this is a problem that LMKD > > > suffers from as well, and perhaps any OOM killer implementation in Linux, since > > > you cannot evaluate effect you've had on memory pressure by killing a process > > > for at least several tens of milliseconds. > > > > Yeah, killing speed is a well-known problem which we are considering > > in LMKD. For example the recent LMKD change to assign process being > > killed to a cpuset cgroup containing big cores cuts the kill time > > considerably. This is not ideal and we are thinking about better ways > > to expedite the cleanup process. > > If you design is relies on the speed of killing then it is fundamentally > flawed AFAICT. You cannot assume anything about how quickly a task dies. > It might be blocked in an uninterruptible sleep or performin an > operation which takes some time. Sure, oom_reaper might help here but > still. That's what I was considering. This is not a silver bullet but increased speed would not hurt. > The only way to control the OOM behavior pro-actively is to throttle > allocation speed. We have memcg high limit for that purpose. Along with > PSI, I can imagine a reasonably working user space early oom > notifications and reasonable acting upon that. That makes sense and we are working in this direction. > -- > Michal Hocko > SUSE Labs Thanks, Suren.