Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp1435385imc; Mon, 11 Mar 2019 13:47:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHN90/Bra7EnKk6co97sEUFRAX4HYTem88DyZvy0Qg8Mk3OeoV/AZFcgfO+E1ksPZKOqdV X-Received: by 2002:a63:360e:: with SMTP id d14mr32115715pga.179.1552337267535; Mon, 11 Mar 2019 13:47:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552337267; cv=none; d=google.com; s=arc-20160816; b=h0QZoEkwEUm/L/L3DiQvisPi5au0wcHNc3iwbe1eqggXnTwc3cLVyUWME1SQj1/Qy/ V0CgOeqk9qzsUpPOdAyXV1S7U+iG9IAxS25ah940vpB/y5FU3NsrYwbWjGZcweJyjVDn KuE7LhXR3nUUA82dmvOsdRqKpTjK7c5nwlsGPYeG8z4zlCGZ0oDTA3uG9Zfp/NaGKk0k uHLoXY9oj+lHPv+wNuJmLowRb2QynGL1BrsJ13dK6Pf3QjYSjAiFj9K9cLRWRlUJr6/H VtA9i1a+m+54pBR4G2DX4AbEJk3BscJNtzN6XlnIVd2CmeK2lBr7fdJ9iEv0/RUUPuFW coFQ== 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=j9c9mo+8DPUzk82qtoerfgEHz5CQacA8eGqE4SQcQfw=; b=GYfxLd2VMY80/Wi7nIwA76WS6namXWqnkDhrNj90ovkjWGn6usFbL5ZWgkVRSKwLIR mFQAkah89+Bppif5RnBsrA0oXoGuzje359y6AunrJPu0S9U9z/tBBTZSrDhIkjT7mgty /YAvpmSGDfRrsHVmAGg4j2RRtwDQ3ZvhqiQegFYm9HDtoliMxDQFuvRWO1/TXwf+D1Z4 3oSCt72h1+L4cH76oLWJ47jXXVP1uU01qHXT/AT4HV1gkz2Qvwsuq9LIPRlbLSq034jC a3ty/RsRuvKbzOHue31tjdf/M4jw/jufJUBTwTQDdTfP2qSGhDOKHFgnrWsu7Fb3f6u8 M3+g== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a16si5452775pgw.75.2019.03.11.13.47.31; Mon, 11 Mar 2019 13:47:47 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728067AbfCKUqd (ORCPT + 99 others); Mon, 11 Mar 2019 16:46:33 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:43547 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726675AbfCKUqc (ORCPT ); Mon, 11 Mar 2019 16:46:32 -0400 Received: by mail-ot1-f66.google.com with SMTP id n71so443632ota.10 for ; Mon, 11 Mar 2019 13:46:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=j9c9mo+8DPUzk82qtoerfgEHz5CQacA8eGqE4SQcQfw=; b=RCLmskJGdvan27ggVGkOH/FIqkvY7hM2Qu8q12xaImMizLeGGNiAWYOWDG4J9mTplA Xtok0rciHIbE1q/T2d9YQtNFbr1mvnp1pUEx7/mj45JEDQF+1dpocJJWt4fElOrl2E1p W2/Y36O2VaNAmEkJ1rREqK3YC1Y13efTI3+dgx8pHpAeZoohHeAMTeRt8tUFj3H4Hyhx aYcrJd1LTkdFNno5gtvtYyk8cleMfJFLZC4GKPIq4DkwgjespL5YKB1XCmYNvUKW9Hwg sA7sKaYkvp2yvn7Dz64+jvI7Oln4Hwhd8odT5bgd9RXWK8423AokBqUMj1JHSpE387pR YfnA== X-Gm-Message-State: APjAAAX9lEOHhUF9rG6aWT5fXlytUNG7uH7Sn1bCtvgb6ive8qMOHvA7 a5Ibhtqk8QhLhEe+w5VVhvQ= X-Received: by 2002:a9d:7b4e:: with SMTP id f14mr21423244oto.141.1552337191930; Mon, 11 Mar 2019 13:46:31 -0700 (PDT) Received: from sultan-box.localdomain ([2600:1700:7c70:1680::21]) by smtp.gmail.com with ESMTPSA id v2sm2621521otk.60.2019.03.11.13.46.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Mar 2019 13:46:31 -0700 (PDT) Date: Mon, 11 Mar 2019 13:46:26 -0700 From: Sultan Alsawaf To: Suren Baghdasaryan Cc: Michal Hocko , 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: <20190311204626.GA3119@sultan-box.localdomain> References: <20190310203403.27915-1-sultan@kerneltoast.com> <20190311174320.GC5721@dhcp22.suse.cz> <20190311175800.GA5522@sultan-box.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) 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 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. > 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. Thanks, Sultan