Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2340650imc; Tue, 12 Mar 2019 11:44:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmSEc6lrwHUX3pMzHtvP+1Ph1SSGmxTwFbwUwa4f3UgkXHF+e92bJ72h6hmuffuvoGXn+4 X-Received: by 2002:a17:902:7d84:: with SMTP id a4mr41789580plm.76.1552416262933; Tue, 12 Mar 2019 11:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552416262; cv=none; d=google.com; s=arc-20160816; b=y8uyd3VxzfkXGvNxAFmvp16h9ZNMCbJGcZUMZCZdAgtYEp5+mTmMYi91gTVfbImYZa xFGbdKDgmo4/xj7oiixWgzD1N+YWQKRogtHBrmORrrkDUgN+KZjDl4ZembYG4WBRpMVY Q1jTKYYkC8ZyLn8G+Gso6LkPh9xs4v13cS7Z5oMj2Lg/V6fj8NwSgkkNzEgjaAdZnfOk E2SOD3Z/zeSX7R8PRhf67tBPk9vyhi8HLie7huFNw1DGENHjGfDwssm3ZOaQhG7wetBw JuknX0Q4YPnpgJGw/1uLnXwr4gIj7tg4vVwQ4ewK799FCi2O6fn/nE8fP4JqTqxJS6bN H3GA== 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=fo/v7SBqR9Y8HorvRV4qY+qTc74qy6r2ZpOJax4E0b4=; b=FtH6UFIx6di24RAtfMcMBnFpdcXxNB5bFn35lJ53g2mbNBagnir3U6fQGu/3Jgf++1 r2C/q/VogsN7+tFM5OsWFqa4w4eokCHNOv7QNwmq3I8JRi3DoQLhAMr9RUQJ95RhLhKL 7TCFJJv55Bm+6bKMjU06ujgmemjlZOeTUvEg7TWkGB1M5QadUir/ATuOln9m7S5uKZtv yrvE2hDUwbRWCOCb9lf/KTxrIKgk+iX/mt6dMRAodPwdWM6C2KPVA6BWhfPSJ1c6qEFi 4B7cGkjdEevGUI3R/g0Ak3/uHjCh4gQNdP+M0nXODLHy8MR2Y3IJYrJ55EuQjWarERGv qPRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OwoZi4sC; 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 r27si8089129pgl.316.2019.03.12.11.44.06; Tue, 12 Mar 2019 11:44:22 -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=OwoZi4sC; 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 S1727117AbfCLSn1 (ORCPT + 99 others); Tue, 12 Mar 2019 14:43:27 -0400 Received: from mail-io1-f53.google.com ([209.85.166.53]:38989 "EHLO mail-io1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726412AbfCLSn0 (ORCPT ); Tue, 12 Mar 2019 14:43:26 -0400 Received: by mail-io1-f53.google.com with SMTP id x3so3017267ior.6 for ; Tue, 12 Mar 2019 11:43:25 -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=fo/v7SBqR9Y8HorvRV4qY+qTc74qy6r2ZpOJax4E0b4=; b=OwoZi4sCHLXm6jIB0SrimzodzEpnuPM1ocHav7KTqC/dNINfGz1ZTNNM/Qor4MM/g0 N+4QizOgiWx6nzvYXPvQ/Cv4V0+kOKHlBD849Q6u93IR06hIERUU+zCuFjk+zYBU0hVW +9wA5VDFmCWUJQo4t4/PMQqmEY68hU97RT4cDqmb03LNd8WglTVlQSADJx8bOSlnFh/h IM6esZI0z3TL94uA0L3h1/beuuBxUp2WaMn2DAMWX4EW2ypY0Ylq3Lr8IdGG/Z4WJy+L nTpuBSvtJn5K6TfhDU/Iupb3+Qq+u8M1sDN4xRN4LTInedhd+UXZkbovRG74KnkZKRpC N40A== 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=fo/v7SBqR9Y8HorvRV4qY+qTc74qy6r2ZpOJax4E0b4=; b=nq3wBLy1k63k65e8NMR8fpv4nYaKfX+crUtHNFaikWq0yIzIMj9zOQmXOOUFLVx+us j51eiuse7UIct8O2UFtVlo9piGZJFhekyD+EkDQhElz7DTUmSEF4J5V2F5gF9yhZKFW4 yHLjvpmqYudQsIXU7H97CHzfSheycHHN+QP53LhuMWklG1OKX/rN4mmMUubsKuUxVTya 3jUpHsAeTzO03hUsyaCb//hVu69L8IIRYucdXuUAznK5fQIYMOIJQqbXrs1EC0o13cjx DneAq//J8dYJOA55V6kg1+d3FOmn6yNhkEJiwSBpZUDbxIfEgFNZgOyCatLVUJBqzRTD UopA== X-Gm-Message-State: APjAAAUN8KpzxccCriBeWo46GA1uhBF5tw/YWa+u7E8InRarL0hvE/0D gPbfX1Z+xWf4ojd9nT2wUTqvgwZB8sVu6oZ4CcYGqQ== X-Received: by 2002:a5e:db0d:: with SMTP id q13mr425229iop.279.1552416204862; Tue, 12 Mar 2019 11:43:24 -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: <20190312174520.GA9276@sultan-box.localdomain> From: Tim Murray Date: Tue, 12 Mar 2019 11:43:13 -0700 Message-ID: Subject: Re: [RFC] simple_lmk: Introduce Simple Low Memory Killer for Android To: Sultan Alsawaf Cc: Michal Hocko , Suren Baghdasaryan , 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 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 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.