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 7410EC02180 for ; Wed, 15 Jan 2025 21:47:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07B4E6B0085; Wed, 15 Jan 2025 16:47:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 02BAE6B0088; Wed, 15 Jan 2025 16:47:24 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E35806B0089; Wed, 15 Jan 2025 16:47:24 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C75F26B0085 for ; Wed, 15 Jan 2025 16:47:24 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4E5A2140349 for ; Wed, 15 Jan 2025 21:47:24 +0000 (UTC) X-FDA: 83011022808.13.96ADE38 Received: from mail-ua1-f50.google.com (mail-ua1-f50.google.com [209.85.222.50]) by imf20.hostedemail.com (Postfix) with ESMTP id 6F4AB1C0012 for ; Wed, 15 Jan 2025 21:47:22 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=yqwAAVuZ; spf=pass (imf20.hostedemail.com: domain of yuzhao@google.com designates 209.85.222.50 as permitted sender) smtp.mailfrom=yuzhao@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1736977642; 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=ltmn9Mm22yVt64ua+/2W5DkLu4FvUvXKpZxg/TWxbvY=; b=QuEKAMrIqJ2FHFhBmtFM1fGRImTnc4YzkrAbGIMiiQAfeyBL80m+jJXOgEUUWDXBIRwSFZ MJKYC0tgPYKWZb+f7XAimXlbnW2Zuypsb6PrvhtEfYNQ1dOH/5Y0lfR8zUfNOiOPP+3GVF gp11XD7yVTskBdV2hgRKp4aQnbwQSQI= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=yqwAAVuZ; spf=pass (imf20.hostedemail.com: domain of yuzhao@google.com designates 209.85.222.50 as permitted sender) smtp.mailfrom=yuzhao@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736977642; a=rsa-sha256; cv=none; b=Q6teskwhbT/OWiMnHv6yJ36pRnf9APmSi4bVwh4Mp8u1C9m0VDUvrP/A/6r5qSBzOmsoTT 0GtyyzTFlBtDPJrlgRtjl4BkxO1q66Ly2rAylXkP2wwiNH+3u9L2Fur6f4PNImCp0zKe+l qlPMvl7VKNdYWcPGdpd0YeQY+lDKzKY= Received: by mail-ua1-f50.google.com with SMTP id a1e0cc1a2514c-85c4557fce0so34706241.3 for ; Wed, 15 Jan 2025 13:47:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736977641; x=1737582441; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ltmn9Mm22yVt64ua+/2W5DkLu4FvUvXKpZxg/TWxbvY=; b=yqwAAVuZoRj1KrTkTANqP3Q3/ZPKaXLKRmcfd4oYz61nnuPPmVDYDCHSvbM1DtJPSl 6MGtu1phoyKbIDIdTG+Mwa2EB14Fq7y3Nyzps18NJn21PKF7T/OCwtY2z/6S6UK5oHp2 iHumSLkpG1sNnfxKC8yCVY6TrgKDYfgLuGm7gdBmsdWm0TCXGBl7wF0/KfGOP6Ax6Usx XKkNKAi2x+KS5u30LOCp7X0GZCUJcAd+VOBTg4bKKlTCeHRh1uKEjWPKM5aEZkdlMVwf OhZGIn9JjnE42el7IE26tMO+ygn7KrM2cpkyUXpXFcSe2cGh/5oWzyGGeV+QkJXnjnot 8VUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736977641; x=1737582441; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ltmn9Mm22yVt64ua+/2W5DkLu4FvUvXKpZxg/TWxbvY=; b=YOEVFQwmn3Iz6YqCtR8w2KGJ8mPdDGoaOnwg7ZNzWwEEIVebIJ12uic38MmLoEcAos VLVsmZEQH9cJqMQJ9NQf1v+QfrnvJHEE0YWZXrDL9ojzyP+JZHhKukbil+Qw6Ggi8bkn AU2bYAtpu66GvXZfL9iZ3xcmhj0rCwafkCaKRZgmXBafRE/8LD/+bYsUY1BSReYKggjO 2ep+2UsbAKQRwYRI508j/wcfKPeFOHlTmGA1FYZ12R+hKJldtFl4St1Uphl1sOLXycFr nMsLUOdpUJCG7cNUROXGREB+5L81rESYLt6BgCvoCTRjKi59aRN58UPyoKGlAhoGpnWK BjhQ== X-Forwarded-Encrypted: i=1; AJvYcCXNB4bkFRWQ+aINR310Dvxsd5rxDrLCy8j9C13/BSuoX3efpQBxVtC2DLM8TCiaAmEc2Uiub0kCBQ==@kvack.org X-Gm-Message-State: AOJu0YzbD408rqDKOKfUnCF/aTHooaTxfaYDpjN9AzYVTxxmb6etjCzq CdJYDYndG0ZjKnPzy+WzlBsIk+eYpMd1WLiv7yDT6zGwguBfmPFsRwsZD9ke6O9T18iuhR2gylw 5uMEYLU1swmeKUzVyaRj+t5/GihjaVm3ykFof X-Gm-Gg: ASbGnctziBMS0sy2A/lDnIp4INSp+YaV2dffcJ8ZmWQlH28oMQfLHFyFCln/OVe/GvX pDCZgdYDH7AnTZb15k1dV05y1HFG94qyxDCIRIVcgu9VCqphLZybTwbK6bhuQbu3Nl8LF X-Google-Smtp-Source: AGHT+IHddxhJJTm91TzdAwSi6uafTRzEfEyn82rLSJiZKUTard4Bp+c3/yQxdvAEMnMOjsCchFbxw41UJMogIcZ05rQ= X-Received: by 2002:a05:6102:54a4:b0:4b0:ccec:c9de with SMTP id ada2fe7eead31-4b3d0ecc1ecmr29653773137.24.1736977641130; Wed, 15 Jan 2025 13:47:21 -0800 (PST) MIME-Version: 1.0 References: <20250115093135.3288234-1-kirill.shutemov@linux.intel.com> <20250115093135.3288234-6-kirill.shutemov@linux.intel.com> In-Reply-To: From: Yu Zhao Date: Wed, 15 Jan 2025 14:46:44 -0700 X-Gm-Features: AbW1kvYmgQZAQoh1evl_F-cwT96TWCJNKl3oZphib0Y46aUVpuxrrUuhtwKH4hA Message-ID: Subject: Re: [PATCHv2 05/11] mm/truncate: Use folio_set_dropbehind() instead of deactivate_file_folio() To: Matthew Wilcox Cc: "Kirill A. Shutemov" , Andrew Morton , Jens Axboe , "Jason A. Donenfeld" , Andi Shyti , Chengming Zhou , Christian Brauner , Christophe Leroy , Dan Carpenter , David Airlie , David Hildenbrand , Hao Ge , Jani Nikula , Johannes Weiner , Joonas Lahtinen , Josef Bacik , Masami Hiramatsu , Mathieu Desnoyers , Miklos Szeredi , Nhat Pham , Oscar Salvador , Ran Xiaokai , Rodrigo Vivi , Simona Vetter , Steven Rostedt , Tvrtko Ursulin , Vlastimil Babka , Yosry Ahmed , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-trace-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 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pPUsgVYReULepU+uP5kwdzYJjs5OOnaH41MUoDRawy5dBqxgs1dhI8PBBJO5iZyLn+9jTt7PY7ZPLK1pRJlYTZOUvtz2ljpNSd04z/fZF1pGupp13rVHzi8BIT/DU+uesPjambP67ZYZ+ivIKZx+BYo9zX7+szdWG2HjOz7wTJqg9kt2Y24lrhAGizzpwlTDPVXCUrNTAWEpvYh+MmEsLK73YvrM6d/6DjUZb6qqlG+Pq8jzhZRlvzb0xWBMJZdAXwYnk8oNdEinpdrk2s54VKWXaWeFAy5SNQ+jAsL1d88N0= 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: On Wed, Jan 15, 2025 at 2:35=E2=80=AFPM Matthew Wilcox wrote: > > On Wed, Jan 15, 2025 at 11:31:29AM +0200, Kirill A. Shutemov wrote: > > -static void lru_deactivate_file(struct lruvec *lruvec, struct folio *f= olio) > > -{ > > - bool active =3D folio_test_active(folio) || lru_gen_enabled(); > > - long nr_pages =3D folio_nr_pages(folio); > > - > > - if (folio_test_unevictable(folio)) > > - return; > > - > > - /* Some processes are using the folio */ > > - if (folio_mapped(folio)) > > - return; > > - > > - lruvec_del_folio(lruvec, folio); > > - folio_clear_active(folio); > > - folio_clear_referenced(folio); > > - > > - if (folio_test_writeback(folio) || folio_test_dirty(folio)) { > > - /* > > - * Setting the reclaim flag could race with > > - * folio_end_writeback() and confuse readahead. But the > > - * race window is _really_ small and it's not a critical > > - * problem. > > - */ > > - lruvec_add_folio(lruvec, folio); > > - folio_set_reclaim(folio); > > - } else { > > - /* > > - * The folio's writeback ended while it was in the batch. > > - * We move that folio to the tail of the inactive list. > > - */ > > - lruvec_add_folio_tail(lruvec, folio); > > - __count_vm_events(PGROTATED, nr_pages); > > - } > > - > > - if (active) { > > - __count_vm_events(PGDEACTIVATE, nr_pages); > > - __count_memcg_events(lruvec_memcg(lruvec), PGDEACTIVATE, > > - nr_pages); > > - } > > -} > > > +++ b/mm/truncate.c > > @@ -486,7 +486,7 @@ unsigned long mapping_try_invalidate(struct address= _space *mapping, > > * of interest and try to speed up its reclaim. > > */ > > if (!ret) { > > - deactivate_file_folio(folio); > > + folio_set_dropbehind(folio); > > brr. > > This is a fairly substantial change in semantics, and maybe it's fine. > > At a high level, we're trying to remove pages from an inode that aren't > in use. But we might find that some of them are in use (eg they're > mapped or under writeback). If they are mapped, we don't currently > try to accelerate their reclaim, but now we're going to mark them > as dropbehind. I think that's wrong. > > If they're dirty or under writeback, then yes, mark them as dropbehind, b= ut > I think we need to be a little more surgical here. Maybe preserve the > unevictable check too. Right -- deactivate_file_folio() does make sure the folio is not unevictable or mapped. So probably something like below would the change in semantics be close enough? if (!folio_test_unevictable(folio) && !folio_mapped(folio)) folio_set_dropbehind(folio);