Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1492785imc; Mon, 11 Mar 2019 15:17:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwpm7kBb3QAgrfftTfZBGCKb1N+Ujqk5M1OQmwOihVRW0QAFfKboHLdc3E/0au7e3SHuDp0 X-Received: by 2002:a63:fc62:: with SMTP id r34mr32162669pgk.154.1552342657399; Mon, 11 Mar 2019 15:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552342657; cv=none; d=google.com; s=arc-20160816; b=e8X1v7GlRZWMp3Bs8rqhiPUnLtYNkUl2XQagkQSZiV9Mst2t/C0cgWK1VWabdGXE1O RGz5hI195ONTW78RHTUdE6IA5WRwt20Rp0D65HKktCU3qKK6LtTip0Evpk9D5KYh0mHo ddXyftHruoWWO5aFmZ0z6mgKVfJ+DPWNH8zgLZHwr02UpzB4pqknvJQUlRmp/G5d3nA9 4PMqSRk+PnL6So1NsHft+AD0ZYOGSbspdNTbBA9E8zeofUBhIzHoiMFjpw3woW/UitaJ es3xEyds2uihlJbsqwOhFzqNAyBNUV721joAZzgRNb3+1eAPnjVw/YHJVne0mhZPitDp Arcg== 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=GnI0fUcdzJqZU/DTruBcUGekoe8aZHTHc7dj/1D9pDo=; b=B3RMDp6ja/6iVIAb54SuXAXa6NgxCnk886X44V7KaMlDS/DyTO17eA0Qh+WTSr2OwC ke6kuJYS+zRQlvcPBx3XzrZkCiqeHbzcabMHCkJKkEObjf/2dOZQzZras1EmUdWeP7A8 IUKzYur++Vcd7KfG8RFHMbCrVKLSKeMod7rnvq86whwSCR0uPjcNh/MsZklrrgS+uTOp lJzcXbJ6QPVrwf+7UX54xRui23ad/U1aHpo/IxWqA16cvBG7xsFhzryvqZ4NlzESVv1/ hOC0oMv7drC4s9cTKSe2yAzx9GPZgvpXLK/gBimW8JTjSdg8rqhZtThYPOmrd7fUl7P/ iUYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=STIu7ueW; 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 k10si1949272pgg.208.2019.03.11.15.17.21; Mon, 11 Mar 2019 15:17:37 -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=STIu7ueW; 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 S1727794AbfCKWPs (ORCPT + 99 others); Mon, 11 Mar 2019 18:15:48 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35485 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727008AbfCKWPs (ORCPT ); Mon, 11 Mar 2019 18:15:48 -0400 Received: by mail-wr1-f66.google.com with SMTP id t18so578602wrx.2 for ; Mon, 11 Mar 2019 15:15:47 -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=GnI0fUcdzJqZU/DTruBcUGekoe8aZHTHc7dj/1D9pDo=; b=STIu7ueW7L5p2TzqtAmcSxV3KguqBPhLN6KQwuyu1G/VOQH2p4moWrluTFiiebcZm1 2ophhi5lSUP4fDVmfI0KcWubjRj4LCAlzmeJpYEmsP8nYT5i/q68XwmRJFtefA3K0hda 59PwzZAiKgBJhKbu6DUDWiNTBR5KSaJ3JNjZLRz3uD2vNTvh2EwFVcQW1x/KYks26Me8 QAYi7AzGhCn/NCSVOfTrKslxmO1dYD4CN+rMR2EYg6sLjWKTb/33PHxfLgv3BOunhxmf RnTqLJ618Y737n7uyVNi0p/Js7fLX03g6gLEgh7tXJqfFwPDOUwY9NPzq6Qblqg0aLsj vSOA== 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=GnI0fUcdzJqZU/DTruBcUGekoe8aZHTHc7dj/1D9pDo=; b=kPv75sWErRbQgPXpK9lddF72ZUxn41Dah/4X6TFa1n1DXK+aK8LIlNjbQ/cWfnRKwH kHIqSVPD4ppu6Uen+hXkF/2+Y57q5xDlQM3zcaZer9G/wJCmxmDyBBPpofSwB2JkxOkv mU6ZIV4mLsiDdnx7UkYumTlv0RRZ6P8VWvYrjLsWpFdfj0IKvMvboTf+0CUxQFasNXGm LanQyNIGqqK34GHQu6H9e+62RNT3uGl7ZDdcYjbje50paxHrex6GvftB5nF8jUYE9e68 oZuj9+g+g/uL0DqnYm4/PsggTmkxTRGPTCya3DScd6zHzDyI+X3jg9pqgSa+sXHZ4Hhh HXuA== X-Gm-Message-State: APjAAAVyN4rjyjKhYM4u9ZZX92bnSuIVsLax7md2YbDYEpNSg2ZcsdQs UGv/tWxyjYbzXupOBCl5/q2HD8SpE09KcswsxjP9dA== X-Received: by 2002:adf:f80c:: with SMTP id s12mr19405040wrp.150.1552342546588; Mon, 11 Mar 2019 15:15:46 -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> In-Reply-To: <20190311204626.GA3119@sultan-box.localdomain> From: Suren Baghdasaryan Date: Mon, 11 Mar 2019 15:15:35 -0700 Message-ID: Subject: Re: [RFC] simple_lmk: Introduce Simple Low Memory Killer for Android To: Sultan Alsawaf Cc: Michal Hocko , 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 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. > > AFAIKT the biggest issue with using this approach in userspace is that > > it's not practically implementable without heavy in-kernel support. > > How to implement such interaction between kernel and userspace would > > be an interesting discussion which I would be happy to participate in. > > You could signal a lightweight userspace process that has maximum scheduler > priority and have it kill the tasks it'd like. This what LMKD currently is - a userspace RT process. My point was that this page allocation queue that you implemented can't be implemented in userspace, at least not without extensive communication with kernel. > Thanks, > Sultan Thanks, Suren.