Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1824869imc; Tue, 12 Mar 2019 01:08:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTM+TN7mYJAr1ecAAhpq13nBn862m8VkuQjKGlv9d8X+rsi4Zu37N5ZrpMNc2z+cxMPMMN X-Received: by 2002:a63:cc03:: with SMTP id x3mr33590628pgf.121.1552378080918; Tue, 12 Mar 2019 01:08:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552378080; cv=none; d=google.com; s=arc-20160816; b=UR/3d4FqbOT7F0RE73pW8FWdlo+czIik9P/IFaSCoHjkscWDZUXs71uJ42Vadwjy7M vXehfoldf2oubw123xU3gN27UGKm7Q0KPjIuoIa9Df4/gU6n8Zt0TNWdor5UUvlRc6h9 ijdAK1arma9+SZAqP7fzZawkc/eEZP+UaPbu2oSAk1qSYl7JpSDoXVFHNstaXHkNKs9i 7sSzGdrrQTE1KnpjL2+ruuw3ISMMgl1SUgQarfsNsD11hYCJdwq8gd1chPkQklabbPc+ Ll9hKRmnGNm4ojeq2SYl9hKtIFqi99RlkR4ZVbNEj0Sj11AQdDL0+LbsQjKU59rdg3M+ ZiSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=PnZH9gEna2A0B89ORaNc6cIrFvLDGY87+yg2rusnRGE=; b=LZmQSitm4StdUIPNJhIx9U8aPOmMTHA44pz8miVRsvLOl/AJ87vtgueOPRHdFLrNBp PH52CZ9r4Zx0UsKO43YA9c1qrC+deY4JwEt9usRkyg6ugy2eKESt4sEH17KzY+uI9wqC D9N/YDepIjjORxzuVygnBtBvGEDBy5AOSiBYoD24F3Vekruhpoq2SxSksAUnKZi9CWgU TB8n/Y8aLp4v72LdDvsv0UkQM9cL8nZIO5X96rubOGXEGYWuaNdc8kKaq5Wr9R2C8VqV tvJ4i6izvhTg6pjIJRGB24kk5UM5GHXnYZ3iDLGEqWZPPXgI2FfuhKaaYzfpJ6cKXG/N EkXQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o188si6928077pga.297.2019.03.12.01.07.44; Tue, 12 Mar 2019 01:08:00 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727457AbfCLIFf (ORCPT + 99 others); Tue, 12 Mar 2019 04:05:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:42718 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726633AbfCLIFe (ORCPT ); Tue, 12 Mar 2019 04:05:34 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 64782B608; Tue, 12 Mar 2019 08:05:33 +0000 (UTC) Date: Tue, 12 Mar 2019 09:05:32 +0100 From: Michal Hocko To: Suren Baghdasaryan Cc: Sultan Alsawaf , Greg Kroah-Hartman , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Ingo Molnar , Peter Zijlstra , LKML , devel@driverdev.osuosl.org, linux-mm , Tim Murray Subject: Re: [RFC] simple_lmk: Introduce Simple Low Memory Killer for Android Message-ID: <20190312080532.GE5721@dhcp22.suse.cz> References: <20190310203403.27915-1-sultan@kerneltoast.com> <20190311174320.GC5721@dhcp22.suse.cz> <20190311175800.GA5522@sultan-box.localdomain> <20190311204626.GA3119@sultan-box.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. -- Michal Hocko SUSE Labs