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 C4B23C77B73 for ; Tue, 2 May 2023 15:26:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5F2D76B0072; Tue, 2 May 2023 11:26:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5A52E6B009A; Tue, 2 May 2023 11:26:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 491EB6B009B; Tue, 2 May 2023 11:26:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by kanga.kvack.org (Postfix) with ESMTP id 2D1F06B0072 for ; Tue, 2 May 2023 11:26:29 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683041189; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=akPo+KEGYmrPGo7TbxAq62xUrfsEw0cvTEcJNIXnSOo=; b=g/dVx99phXVAY/BUsdDoMecwGnxjGxYhZv8qdpmEsgDnDJ5vR3PoVjh/tDEhWEh4SpWB37 5khr5DFarGkRgBCHoW2VoOOXieNYJkATdw9+ayERluXDNyxppUKudwqZQHDomqoQ7dkEiB r2ttXBQfiTDYhKwQ+IniUqHL3DSFlbI= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-122-M_jKsSagPzaSt2Mi-bIjKA-1; Tue, 02 May 2023 11:26:27 -0400 X-MC-Unique: M_jKsSagPzaSt2Mi-bIjKA-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-61b5f341341so2572176d6.0 for ; Tue, 02 May 2023 08:26:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683041187; x=1685633187; h=in-reply-to: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=akPo+KEGYmrPGo7TbxAq62xUrfsEw0cvTEcJNIXnSOo=; b=F7IzWprsLeoJJIXxXfio3wNxf8mVYdJNI8nr2vPcZygiSZYYytkEmUom9rjzNnKsMn G4WEt+9CtGZaL6+u/Gtt5CUgE+953TAwvugAOAYW+XhxalBNcTJr1qe4O/r9Ok/87AEo LivOvwwRZUMuB/LrBHuA66RIYMVHjyZJSatfD3yPNkMwcrwKMkTordT+GDQMcw8/I/Q2 n58xgKqCox/LsEZBNF/oUHU8VoBJal1EDR4eTTugUmUsDE+FF3Y4g1LMXKHUsAwzpTiB hnW8huJo72/QdAzXONTAfwwmVFh89NbRLbXGz3wPKRHmfIIqjafKtGW2FWm2VZ6irTWS HEpA== X-Gm-Message-State: AC+VfDx0zWXqQiyfOlNaupFcS/ur6kopm1LXUFBfV7bvlJPyPiwXcg2x BBYyOwE96AaKpvvGeoTUfIIePs83paeufhtOlcAa5YD05BlL39PezVHJ9uCe2Yw8GFLmFtEG/IN 0Yuxq8TrJ29s= X-Received: by 2002:ad4:5fcf:0:b0:61b:6b8e:16e0 with SMTP id jq15-20020ad45fcf000000b0061b6b8e16e0mr2257107qvb.1.1683041187455; Tue, 02 May 2023 08:26:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7JHOpeTuTrkxkrIFVKlTemcyqHPBbWZl+er1BpBHHrIGnRkOX888+uNoF/CwVWZpV2ykDgEQ== X-Received: by 2002:ad4:5fcf:0:b0:61b:6b8e:16e0 with SMTP id jq15-20020ad45fcf000000b0061b6b8e16e0mr2257084qvb.1.1683041187220; Tue, 02 May 2023 08:26:27 -0700 (PDT) Received: from x1n (bras-base-aurron9127w-grc-40-70-52-229-124.dsl.bell.ca. [70.52.229.124]) by smtp.gmail.com with ESMTPSA id u16-20020a0cf1d0000000b005ef42464646sm9585700qvl.118.2023.05.02.08.26.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 May 2023 08:26:26 -0700 (PDT) Date: Tue, 2 May 2023 11:26:23 -0400 From: Peter Xu To: Jan Kara Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Lorenzo Stoakes , Andrew Morton , Christoph Hellwig , David Hildenbrand Subject: Re: [PATCH] mm: Do not reclaim private data from pinned page Message-ID: References: <20230428124140.30166-1-jack@suse.cz> MIME-Version: 1.0 In-Reply-To: <20230428124140.30166-1-jack@suse.cz> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline 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: On Fri, Apr 28, 2023 at 02:41:40PM +0200, Jan Kara wrote: > If the page is pinned, there's no point in trying to reclaim it. > Furthermore if the page is from the page cache we don't want to reclaim > fs-private data from the page because the pinning process may be writing > to the page at any time and reclaiming fs private info on a dirty page > can upset the filesystem (see link below). > > Link: https://lore.kernel.org/linux-mm/20180103100430.GE4911@quack2.suse.cz > Signed-off-by: Jan Kara > --- > mm/vmscan.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > This was the non-controversial part of my series [1] dealing with pinned pages > in filesystems. It is already a win as it avoids crashes in the filesystem and > we can drop workarounds for this in ext4. Can we merge it please? > > [1] https://lore.kernel.org/all/20230209121046.25360-1-jack@suse.cz/ > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index bf3eedf0209c..401a379ea99a 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -1901,6 +1901,16 @@ static unsigned int shrink_folio_list(struct list_head *folio_list, > } > } > > + /* > + * Folio is unmapped now so it cannot be newly pinned anymore. > + * No point in trying to reclaim folio if it is pinned. > + * Furthermore we don't want to reclaim underlying fs metadata > + * if the folio is pinned and thus potentially modified by the > + * pinning process as that may upset the filesystem. > + */ > + if (folio_maybe_dma_pinned(folio)) > + goto activate_locked; > + > mapping = folio_mapping(folio); > if (folio_test_dirty(folio)) { > /* > -- > 2.35.3 > > IIUC we have similar handling for anon (feb889fb40fafc). Should we merge the two sites and just move the check earlier? Thanks, -- Peter Xu