Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2346217imc; Tue, 12 Mar 2019 11:52:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqKEoAZuS7toeb4lelrELYxOiwVIT9Yz82ua9RVIpr1hXWoUOnpxvg6dSXHcr+u6/Yxlr8 X-Received: by 2002:a63:2c8b:: with SMTP id s133mr36179307pgs.448.1552416727244; Tue, 12 Mar 2019 11:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552416727; cv=none; d=google.com; s=arc-20160816; b=sT0j19yI2orV1nP0wzJlGmU3TFYcLMw8I1DCnqYNPc9AZbKls6gJWF0XUtbjPCvUHn Bk+93zKI4XX82nkHNFtgE5hQbAsaNIzdoGFOxKw0QjANDnU5TuSYeaAJC/zzmZgu+XiQ ETU7ZAV//k/b0ieYNZh2BJ2irNGAHvE1y9JZ+5hm1Bjaaf+5MciRiyFeljYKda8jI6G5 D7m8i0LAl/pqm+G2jLlP3w9a4xBdQGiHQQmNeYB/CWPLIibpFnhGwvSZu45ftv1dlXML RBXfLRlxxkN00kjk1Fz7KoP24k1ccHwG2noXLioiA4bkXQQ2eOr3qmG3lBz+VEucqyI7 6zwQ== 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=Mm1QjN0w8dacwGXEVgLh1zGRWMMMxD/FUwmSzd/yuf8=; b=OXOudYN3LjoLr4A9aTqYSgSV55kXVwTvd23a5wyNTXcmmIt1kD12z/RMA2UxKQ5Udj vTsNmRv8/wQ+XnQSWNAiGZZ+N9pWJqTXUtkbfdIFO97Rcwkdnr/OBbpVOlDbafsvgKhK dJ0Yvwy46x5UOhanb921o4JN1pdlOKjxvLuDHM0Qjq+L5c4SWAzbKzLGaXYTx+Hyu9aB kH/citAg/USa3Nq5CBQaBT/wRFBGTvqCkas8KyIqjmc/dz4tbKia2HNSiodHA7E+B3BI 0go8H9pqxb5Ze/E/I0pvzbQItXlOOeDLOEwExq7QBxbKTYLOhILlaj9KIyL0ZExnaN2K J56Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=ReZ7TFra; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q207si8002118pgq.321.2019.03.12.11.51.51; Tue, 12 Mar 2019 11:52:07 -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=@brauner.io header.s=google header.b=ReZ7TFra; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726883AbfCLSvJ (ORCPT + 99 others); Tue, 12 Mar 2019 14:51:09 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:46067 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725894AbfCLSvJ (ORCPT ); Tue, 12 Mar 2019 14:51:09 -0400 Received: by mail-lj1-f195.google.com with SMTP id d24so3249727ljc.12 for ; Tue, 12 Mar 2019 11:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Mm1QjN0w8dacwGXEVgLh1zGRWMMMxD/FUwmSzd/yuf8=; b=ReZ7TFratJ9POYe6uENAlwtgGehDAzQ2wCByC5K5jWadZKihhqNohXxG6TJQKQPbQM Z2fBsTi4n9dUsdHgFXbDNVqnCfzUp8UG4J4TXogC9BIeJE7mVvjgjdV2QKQ3EWDZsVcV 0GWRm/8L5yezYHi9shNQtX5EWu81grR7bJQvyzJrys7kBYxQc3TCEXJvVb9cv3oR7YTA jRoAVYCvsLhSmCgM3v71misWrrC8WCrbGHvpbwr0Yw5zMIvqGbFjLKdxO/jWUO/eNMv5 zkj8CKXLtQ2OxjJPT/o56vzm5sk5BpJ26RbliroOVQqmDBfM/pwErxR90ONVv/lB84ox F7IA== 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=Mm1QjN0w8dacwGXEVgLh1zGRWMMMxD/FUwmSzd/yuf8=; b=GxX319c6uMcOAehrUGGGTAT0d7SpHDX8mHAlFuHDT8J5MuYSO0OkzCAOss467pqtbG Vkrcjk+nPF/k9z2dt6d/pjZQoR9MLctXSQ78B1aOQsJWA27A1K5YMmb1Vdk6STWdz+x4 Duwg3uIFzFS0HMZyKdiCcD2HR8SCHEa11QC5nb5x0HcXG0+i2JKW0reROF/LyqKLCq4f Q4Z+nmwI9jICJYFxEVZQD0TsQxrugKQWfMj4EaPkMTLbO1ZzNL6tXlM0M7udlDr6BRql UOzqVAalPxiM86fl4wFYEiLzXxZv7khD6UVEVWn8NoJlSzKe0GGw1WBq2ZtiZpPeidvN TJ2Q== X-Gm-Message-State: APjAAAXAASiVfdVJDv6aUEXaQfp6DMyi2cU8QiTWpEE7OCKyYoT/byyx Oo296m9hmQovwAltUghxQqP3Bgv2k8pqswcrjUxSvg== X-Received: by 2002:a2e:b014:: with SMTP id y20mr10013024ljk.116.1552416666852; Tue, 12 Mar 2019 11:51:06 -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> <20190312163741.GA2762@sultan-box.localdomain> <20190312174520.GA9276@sultan-box.localdomain> In-Reply-To: From: Christian Brauner Date: Tue, 12 Mar 2019 19:50:56 +0100 Message-ID: Subject: Re: [RFC] simple_lmk: Introduce Simple Low Memory Killer for Android To: Tim Murray Cc: Sultan Alsawaf , Michal Hocko , Suren Baghdasaryan , Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Ingo Molnar , Peter Zijlstra , LKML , linux-drivers , linux-mm 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 7:43 PM Tim Murray wrote: > > On Tue, Mar 12, 2019 at 10:45 AM Sultan Alsawaf wrote: > > > > On Tue, Mar 12, 2019 at 10:17:43AM -0700, Tim Murray wrote: > > > Knowing whether a SIGKILL'd process has finished reclaiming is as far > > > as I know not possible without something like procfds. That's where > > > the 100ms timeout in lmkd comes in. lowmemorykiller and lmkd both > > > attempt to wait up to 100ms for reclaim to finish by checking for the > > > continued existence of the thread that received the SIGKILL, but this > > > really means that they wait up to 100ms for the _thread_ to finish, > > > which doesn't tell you anything about the memory used by that process. > > > If those threads terminate early and lowmemorykiller/lmkd get a signal > > > to kill again, then there may be two processes competing for CPU time > > > to reclaim memory. That doesn't reclaim any faster and may be an > > > unnecessary kill. > > > ... > > > - offer a way to wait for process termination so lmkd can tell when > > > reclaim has finished and know when killing another process is > > > appropriate > > > > Should be pretty easy with something like this: > > Yeah, that's in the spirit of what I was suggesting, but there are lot > of edge cases around how to get that data out efficiently and PID > reuse (it's a real issue--often the Android apps that are causing > memory pressure are also constantly creating/destroying threads). > > I believe procfds or a similar mechanism will be a good solution to this. Fwiw, I am working on this and have send a PR for inclusion in 5.1: https://lore.kernel.org/lkml/20190312135245.27591-1-christian@brauner.io/ There's also a tree to track this work. Christian