From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EADD6C369C2 for ; Thu, 17 Apr 2025 12:18:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF37C28008F; Thu, 17 Apr 2025 08:18:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AA0DC280088; Thu, 17 Apr 2025 08:18:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 940F928008F; Thu, 17 Apr 2025 08:18:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 74F16280088 for ; Thu, 17 Apr 2025 08:18:03 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E8A3B1615B7 for ; Thu, 17 Apr 2025 12:18:03 +0000 (UTC) X-FDA: 83343437646.21.53E5F43 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) by imf15.hostedemail.com (Postfix) with ESMTP id B2BD4A0008 for ; Thu, 17 Apr 2025 12:18:01 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=i9lNoWPW; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf15.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.53 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1744892282; a=rsa-sha256; cv=none; b=DmeyQ2O+sbGK2d8Q0gZ0v5nknPR9d9Z9bn28bAG1lisUfpTbcsuQBeeEMPbxOhuWI6eRtk NG9Icq7OXRprRbt/bbxSw7a2sQEAjtmwrJdTPe0gluUYHcLBXvzzWHayxvypepElT4MTbX +GMTGAs7TJK0dPyu8hCQznvHdHXtrTU= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=i9lNoWPW; dmarc=pass (policy=none) header.from=cmpxchg.org; spf=pass (imf15.hostedemail.com: domain of hannes@cmpxchg.org designates 209.85.219.53 as permitted sender) smtp.mailfrom=hannes@cmpxchg.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1744892282; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=6zGWREKiNSbSEtD4UDjmKU/QdI2LbKnHVnU0n3Ksd+g=; b=AK+b0Wy+fgeYY07yLdZ/o3U5YeXr6y7xsbmOs/urLzG8X1fnIYWsHK4KscNlB9MTCReKPZ 4rVd3pOOGEwvUJOzif+QMoyqUNnrR4gSRvT8C6z90ta2PqQto5VCgJzjoBTB4amLgoIQvH ekKHLl4cuHK5tvk9tfoloW9LTsLDsXo= Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6f0ad74483fso8271526d6.1 for ; Thu, 17 Apr 2025 05:18:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1744892281; x=1745497081; darn=kvack.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=6zGWREKiNSbSEtD4UDjmKU/QdI2LbKnHVnU0n3Ksd+g=; b=i9lNoWPWo0UUfxCHeJHdM8/rYHXE2hSPixmXQ5drKA02FUDvBVP/Bxs01OzWPAuidy 7h9pnuXMNptt3sso15nEq++E44cFjuA5OKC0Vmt7wp8eRxfl4Lw0ecFBlCxevRkU+C06 DrrQPvfUUuCV3XL3awaTIqLKlJ1dU/ZwF5ulSCuK0YJALtoVlwS/gF4liQ1nCdvMOh80 /RY18WxjplyJgNnT10EUZlY+FooGmIdMpPd3XqZayj2QVDyHSOwFDeIBJZHQHKt2xwDi DwygaRpFUPTSeYh1obMsc1DZ4hN2VnJo8+g4J2Yj/9VnGZzGtQblaPizxRGvWytczUBT Z4rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744892281; x=1745497081; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6zGWREKiNSbSEtD4UDjmKU/QdI2LbKnHVnU0n3Ksd+g=; b=O+4XZalwhhIQsKxkIjwPHnbsmFk2lWGbLdllBNE7jXrsB5ezPe4S+MjQS0ilQ12F29 8lqC+W+tRf93V3z6ZNrXMV68LuRWa9gtZBWXUSRhW5NM/yCuOGRdcy2V92FawJupWL2X DIpqZ+6ccmvaJBg8IagnNtE2qSe6ViKu224E+PYE8BVeMuhAbMx92Gh3rzFWBEzceaPA rH9oUEJo2KrnAqi9nqfLpd/Tr1wMSWAlkR7jLNjU3RHL/LsWqdRdY5h5jdV0ToYe3FBi x9e64MbMLXew12lJty/dj7dqvNzTOEpNeFqHps5HmGpEoFD65LgC8uA0d/zw8ry5hGEf aijg== X-Forwarded-Encrypted: i=1; AJvYcCUKLa79w2BF+d4e5k/jdXXIQLy/oThpIL4ztmtAt4PUV5nakIv6gYkuM1E1jJ9JVnFDDKzvze5m4Q==@kvack.org X-Gm-Message-State: AOJu0YymTsyEc8vaB/YRlc5IfULW2DkIzjXk3gs9Zx0bugNoIm5DHzNr jrJYiXE3oAhqSBMCUSq2AysWI5b5IkMS/pPfOzWdIR2/MGP7H2vIrWMJEddxFlY= X-Gm-Gg: ASbGnct3GzB2VvKRl82JOOE2WLejqzrsMkDIowSUYU7ht7b2OPfs+vxr6RutauhkUTa C4QP+RgA2DRE36pVomUqOqBqC6JHEGlxua4a2fx3GYcJouxc3VO2wA1QN/jHQHa6HXtiOeIxXoP 84g568Rzsexpo6hVnBfjYFCE+UNKK1gULhT76YyvTrxyFZS3lCXNBLQ1cS6xIVTA6oO+FMC4Nxc WTXb2EOrD/gsXaw/DmdPxUKirm7srpLV1Kt8X3T+QzEJYw25Typi1z1PHIRJ5FyZCxfIOHi4NMe cD+ziQw/A6+xIr7gGJSHcFLucWxgLCw9liXt/88= X-Google-Smtp-Source: AGHT+IHqIQIkHHKFNpzRwxoPPSkGF/U7CIZx4JLl8hQ4M4aX6BdWZoE18416/VYbXnz2bZdENGdsrg== X-Received: by 2002:a05:6214:5293:b0:6e4:7307:51c6 with SMTP id 6a1803df08f44-6f2b30516c4mr96452066d6.34.1744892280753; Thu, 17 Apr 2025 05:18:00 -0700 (PDT) Received: from localhost ([2603:7000:c01:2716:365a:60ff:fe62:ff29]) by smtp.gmail.com with UTF8SMTPSA id 6a1803df08f44-6f0dea07d4csm126932316d6.84.2025.04.17.05.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Apr 2025 05:17:59 -0700 (PDT) Date: Thu, 17 Apr 2025 08:17:55 -0400 From: Johannes Weiner To: Barry Song <21cnbao@gmail.com> Cc: David Hildenbrand , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Barry Song , Baolin Wang , Matthew Wilcox , Oscar Salvador , Ryan Roberts , Zi Yan Subject: Re: [RFC PATCH] mm: don't promote exclusive file folios of dying processes Message-ID: <20250417121755.GB780688@cmpxchg.org> References: <6259cc1d-93a8-4293-9009-a6119166f023@redhat.com> <20250416141531.GD741145@cmpxchg.org> <239cfe47-9826-402b-8008-de707faa160e@redhat.com> <20250416181835.GA779666@cmpxchg.org> <20250416235849.GA780688@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: B2BD4A0008 X-Stat-Signature: 34m64j7oo6fjidsu7nbmooj46z4bbjwr X-HE-Tag: 1744892281-389606 X-HE-Meta: U2FsdGVkX19Dy1W9lfxSkAEmQIyTNlH1/BXKb1BC3kf4t45XmOpoTeYd33delgaUJ8gNT/Q1R5Moy7rE/Nf8PCGIZgt/EMABw+fU0SPJ5FUAx87jCyjJ5hrBe7Kx7HXOZn7xGCViwK0JJBxVFiSxUByqLIzAxnFY5JM/FsvYXR9hT2ZFMiBvDbl4yV+D3INpKf9xcq2qojdba7iONH12yDL4LIWCu9UpkMmrel7d7fFrqPqhwnLGPJDfrhCh22jGnaIkCyjbV+d7RfHktDVjyMgU9VsaqsJFqSY/r5v52ONx8QwCjuhJ7wUuai/9UL+fAaZBVL1GjNwRcOxCYGqcI7mTuwgz9VukgwURtbXs8iFoazPFGkd6V8LbjOc4THwrDSziPrjvn/LMzVIHqlGXcwae39onpZ8N3CkC8EIbytwwW3ACecAI9mKm4KlgoKpIdJx2DLxhaw4kV8G5fRIqhpGk850kLIbWfcJElOjuotgpH2+8kM5VDCLLllv5aW3uRcA+/1blq05lMVmtcQyoN5ZQk1cIR62VVgWs8RLCfC7prBUMDlS+E0QyieClcrfm9+PEtxASQNkw8yNxkmcOuKrbO7JPs6Z+qqDJ1XB6+e8crkec3++1mzfEPDOBAPRUlG4leZVHQtMTbBFb2aoUaSIcpsgEqWZuISD7k2iWPJrA5wIUfBqPm+ns0/Anl6+dDTOi05MEd3g/bEH3Hc5U+NcBGzPtSl7+p3xU3s6QMc8oKUtcAes3CZUcPKRWloC4uHBsN1ZoFL1RExz07WHZEx4gT1m8J57He2Z45Z/UcUdbvf36gILAsfRFXP5UlI9KPWihlAzb7RZ8Aqv6BH8Ku36M7MXCqhk5dTVZ6LIUQaqE4JLRi3jGuXcVcVmGIKwzMtbXidp3ydPkMNhfCLv9cB6j6jANh2nq2ARiTA3EtKfb5JkoDWaOIuSG1OUm0gOIrwRbeZVSbr+IPfXOW2I NrBaAKBX qkC8C7C22fML/Bk8cLR1ZnN7VA4dUgtMPyKECV2tGFBUoBfKSvkb/TL6F0GtPzakmP/vaW7XYWzhAiHWgSzMe3D3B8QrY9qqEM+t4+J91osaKF1XEjSbjIooAGLU1H/Ob/y3p40DSBUy3/PALRRQ76YdJlIoSybPE1SZwpQqm+39y2pLfer/jnGNdL+eJ5PYgMmQwaWUFSz6NUqv7pR9ozxCAOMjemgHpgrgi5685Zs1tmbZSARkRqEw+NuimCxoDGFE6RtuhCw0ybmZz3o28Tl7d14cVQqOjsjegIBVGT4oriZAPcUk6FRTo+ljkMVYYHkVkvWh2k3VowppI99dg2rPcFja4Tppg55wUgkzAEx4Mv4ZUaSV2BmHzRwGxLkfKok1Ci9FRz+tADJpZcT2albbQix1povozLCKCjFPtfssOivW0ecPFvxi+FwqK/VD2dn7vjI1kkjW+tUDkPnJh73YvgRKB2VoL9bPVNTDujz/Iho19f/g7r9vVl+KnusmAIK3M X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Hi Barry, On Thu, Apr 17, 2025 at 10:43:20AM +0800, Barry Song wrote: > On Thu, Apr 17, 2025 at 7:58 AM Johannes Weiner wrote: > > On Thu, Apr 17, 2025 at 05:54:57AM +0800, Barry Song wrote: > > > I agree that "access locality and recent use" is generally a good heuristic, > > > but it must have some correlation (strong or weak) with the process lifecycle. > > > > I don't agree. It's a cache shared between past, present and future > > processes. The lifecycle of an individual processes is not saying much. > > > > Unless you know something about userspace, and the exact data at hand, > > that the kernel doesn't, which is why the Android usecase of MADV_COLD > > or PAGEOUT for background apps makes sense to me, but generally tying > > it to a process death does not. > > I agree that MADV_COLD or PAGEOUT makes sense for background apps, > but I still believe process death is somewhat underestimated by you :-) In > Android, process death is actually a strong signal that an app is inactive and > consuming much memory—leading to its termination by either userspace or > the kernel's OOM mechanism. That's exactly what I'm saying, though. You know something about userspace that the kernel doesn't, which results from the unique way in which app scheduling and killing works on Android. Where you have recent foreground apps, idle background apps that you can kill and switching back to them later transparently restarts them and shows the user a fresh instance. But you have to admit that this is a unique microcosm modeled on top of a conventional Unix process model. So this doesn't necessarily translate to other Linux systems, like servers or desktops. There is much higher concurrency, workingsets are more static, there is no systematic distinction between foreground and background apps (not in the Android sense), OOM killing is a rare cornercase most setups ususally try hard to avoid etc. But surely even Android has system management components, daemons etc. that fit more into that second category? > We actually took a more aggressive approach by implementing a hook to demote > exclusive folios of dying apps, which yielded good results—reducing kswapd > overhead, refaults, and thrashing. Of course, it is even much more controversial > than this patch. That doesn't sound wrong to me for Android apps. How about a prctl() to request the behavior for those specific app processes where you have clear usage signal? And then by all means, outright demote the pages, or even invalidate the cache. Delete the files, discard the flash blocks! (Ok that was a joke).