Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp11019ybm; Tue, 21 May 2019 21:26:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqySRLJmy7LZlm1nr6mxHU3J3RVRICX5+tqIkt1yQIdTQYHZeTN0dd9SXk1vGkfgWG7BYcET X-Received: by 2002:a17:902:7082:: with SMTP id z2mr64744475plk.176.1558499174724; Tue, 21 May 2019 21:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558499174; cv=none; d=google.com; s=arc-20160816; b=k7MCvReW/vfIXph81uBRqcFAgj+jb4T1zfMDu0s/vJYGjbx7FQvcYg/y9HLJT8Yht9 w3A/mDKtFiGkFYZvkfS3iBDHZiT14mZOxw37ZFyYG5Cp2dFUJrZABFHF6comoHZo5hhj 83myJxjfbZPLG8wQ3ALgIdNvVdJ7ScqZR8L6nDk7/7OzRHInad9z9mcHM470r0ufJSCt U7csoDcHVxvzx82Er4QaMA27wHvA6xjy1CAXpHaGdgh6iLJeQhBGYkcApKe/71cOcEr/ WKVzsRbbFFdvsT9mfdbxrIVNJEm0Z5X3TgXmASzjMc6/6lUggZotzppAPTYnMeNyRski N3KQ== 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=+NQu0NI8ncRqI8fsVQtJ0PPb5XIcqSyNmrQ1DHUlIgA=; b=PPqLALeN5r5zm8IsoheDfEsx+iAGVRQrWPFvejxvNZqPTeVT0jScNEUMR45VFEFcED MGHkLoRK241w+TY0+e3s3GAVzM+zGRTzLa+rw2Y13teQlQVfpcQJj39uH97DUQV61yXe Z0VmzQKJLgnFZu4OzpOG009/BkTKqC70JogSuEJNv1XN2EFIzuYlvXhLGC23ipxZfA0/ WksvadYObEogEd82MNOcNugH2WJUwfqCmNWoS6F62wRkh5v9XZfPgIddBUDneNBz85NI DB7fbP/zJTGcpVkIZyfrHjMBkDvBczWCrAGG8hm49HQfhaUPUDuxA8KW1xEVoV8n/Igq E21A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cTctEi3a; 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 30si24103316plc.8.2019.05.21.21.25.50; Tue, 21 May 2019 21:26:14 -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=cTctEi3a; 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 S1726217AbfEVEYE (ORCPT + 99 others); Wed, 22 May 2019 00:24:04 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:44109 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725796AbfEVEYE (ORCPT ); Wed, 22 May 2019 00:24:04 -0400 Received: by mail-ed1-f67.google.com with SMTP id b8so1656195edm.11 for ; Tue, 21 May 2019 21:24:02 -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=+NQu0NI8ncRqI8fsVQtJ0PPb5XIcqSyNmrQ1DHUlIgA=; b=cTctEi3aTljPqIa9jevUUtkhUYP6k7DFrA/xHnftumm9ApHTJKy3N++7Ueoj0t2YuR GqtafLyvkH2P4JExAvskMZj3A+phaDWwFHrdXLM5Q9UZw4i4ZPRvt4R4WScaJZ0QxMvh rsoFhFnx/DRaxyTPlryjIEHTPtMsJi8CGRuw9mz8pc53fXK5Y5dHApQF2uGnifIy/9aA KDgZVDf2tH57ieUxk0C9OSNHKLsLTL6tAD+m436cT3jECDzLtJfQnw69G5l+euN9240+ 5vYHG/3HNGySzVeHP4I7Bw7WhrwBfcwQIX7ZmqYPgwOsow8gxFB1vjkoBZHwClOkmyoW 2aYw== 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=+NQu0NI8ncRqI8fsVQtJ0PPb5XIcqSyNmrQ1DHUlIgA=; b=F51IH/m6IQyX70OQFYVTV/s/NFJGufFplo0XG9aU/ii6gKvrbW/qJhuD2a30iKiEVt x6JC3OteK4WMDQxjLMovGsBw9QmMBHXTHCK/IxVFahrbepc5AbBZ/48AMd90EktKUllV 0IP9FmxpBe6X0v9KoOGC6+8HmS1siqgH1gFjqiCSNwC+gmir19KWn51nNpqD9oiC+Pe3 ZqGN9Gmfi4FQXPvIdHmcKTxz1fULTmKoDE7ec6NEKGG/iW/5I4ocBoh2/37b3DxpaRQI CSDmgfkHFjd6jymfxx7TJ51Df+Zwlms/h9exdgm6jmpiUsHAed6TskkC+XGbi1RDNMwl 393A== X-Gm-Message-State: APjAAAW+OlKuh9nQRRIoXebpph2LqImSNUOUoXyDEjvMPiFaQv+PH5pw fJylORi5DgV8UDd0lbQVCvDV1w3Gj5/Dv0j6ls9Zme/2/pRMiicv X-Received: by 2002:a50:9264:: with SMTP id j33mr85821109eda.125.1558499041640; Tue, 21 May 2019 21:24:01 -0700 (PDT) MIME-Version: 1.0 References: <20190520035254.57579-1-minchan@kernel.org> <1754d0ef-6756-d88b-f728-17b1fe5d5b07@arm.com> In-Reply-To: From: Brian Geffon Date: Tue, 21 May 2019 21:23:35 -0700 Message-ID: Subject: Re: [RFC 0/7] introduce memory hinting API for external process To: Shakeel Butt Cc: Anshuman Khandual , Tim Murray , Minchan Kim , Andrew Morton , LKML , linux-mm , Michal Hocko , Johannes Weiner , Joel Fernandes , Suren Baghdasaryan , Daniel Colascione , Sonny Rao , linux-api@vger.kernel.org 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 To expand on the ChromeOS use case we're in a very similar situation to Android. For example, the Chrome browser uses a separate process for each individual tab (with some exceptions) and over time many tabs remain open in a back-grounded or idle state. Given that we have a lot of information about the weight of a tab, when it was last active, etc, we can benefit tremendously from per-process reclaim. We're working on getting real world numbers but all of our initial testing shows very promising results. On Tue, May 21, 2019 at 5:57 AM Shakeel Butt wrote: > > On Mon, May 20, 2019 at 7:55 PM Anshuman Khandual > wrote: > > > > > > > > On 05/20/2019 10:29 PM, Tim Murray wrote: > > > On Sun, May 19, 2019 at 11:37 PM Anshuman Khandual > > > wrote: > > >> > > >> Or Is the objective here is reduce the number of processes which get killed by > > >> lmkd by triggering swapping for the unused memory (user hinted) sooner so that > > >> they dont get picked by lmkd. Under utilization for zram hardware is a concern > > >> here as well ? > > > > > > The objective is to avoid some instances of memory pressure by > > > proactively swapping pages that userspace knows to be cold before > > > those pages reach the end of the LRUs, which in turn can prevent some > > > apps from being killed by lmk/lmkd. As soon as Android userspace knows > > > that an application is not being used and is only resident to improve > > > performance if the user returns to that app, we can kick off > > > process_madvise on that process's pages (or some portion of those > > > pages) in a power-efficient way to reduce memory pressure long before > > > the system hits the free page watermark. This allows the system more > > > time to put pages into zram versus waiting for the watermark to > > > trigger kswapd, which decreases the likelihood that later memory > > > allocations will cause enough pressure to trigger a kill of one of > > > these apps. > > > > So this opens up bit of LRU management to user space hints. Also because the app > > in itself wont know about the memory situation of the entire system, new system > > call needs to be called from an external process. > > > > > > > >> Swapping out memory into zram wont increase the latency for a hot start ? Or > > >> is it because as it will prevent a fresh cold start which anyway will be slower > > >> than a slow hot start. Just being curious. > > > > > > First, not all swapped pages will be reloaded immediately once an app > > > is resumed. We've found that an app's working set post-process_madvise > > > is significantly smaller than what an app allocates when it first > > > launches (see the delta between pswpin and pswpout in Minchan's > > > results). Presumably because of this, faulting to fetch from zram does > > > > pswpin 417613 1392647 975034 233.00 > > pswpout 1274224 2661731 1387507 108.00 > > > > IIUC the swap-in ratio is way higher in comparison to that of swap out. Is that > > always the case ? Or it tend to swap out from an active area of the working set > > which faulted back again. > > > > > not seem to introduce a noticeable hot start penalty, not does it > > > cause an increase in performance problems later in the app's > > > lifecycle. I've measured with and without process_madvise, and the > > > differences are within our noise bounds. Second, because we're not > > > > That is assuming that post process_madvise() working set for the application is > > always smaller. There is another challenge. The external process should ideally > > have the knowledge of active areas of the working set for an application in > > question for it to invoke process_madvise() correctly to prevent such scenarios. > > > > > preemptively evicting file pages and only making them more likely to > > > be evicted when there's already memory pressure, we avoid the case > > > where we process_madvise an app then immediately return to the app and > > > reload all file pages in the working set even though there was no > > > intervening memory pressure. Our initial version of this work evicted > > > > That would be the worst case scenario which should be avoided. Memory pressure > > must be a parameter before actually doing the swap out. But pages if know to be > > inactive/cold can be marked high priority to be swapped out. > > > > > file pages preemptively and did cause a noticeable slowdown (~15%) for > > > that case; this patch set avoids that slowdown. Finally, the benefit > > > from avoiding cold starts is huge. The performance improvement from > > > having a hot start instead of a cold start ranges from 3x for very > > > small apps to 50x+ for larger apps like high-fidelity games. > > > > Is there any other real world scenario apart from this app based ecosystem where > > user hinted LRU management might be helpful ? Just being curious. Thanks for the > > detailed explanation. I will continue looking into this series. > > Chrome OS is another real world use-case for this user hinted LRU > management approach by proactively reclaiming reclaim from tabs not > accessed by the user for some time.