Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7953131rdb; Thu, 4 Jan 2024 13:08:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5GweUhRq9W17/KuyALI67N4EQ+Vcix10g4zN/Eoj8HRtgODrYDBIWWtSiIRuBHtk9KTrS X-Received: by 2002:a50:c04b:0:b0:54f:51cc:6570 with SMTP id u11-20020a50c04b000000b0054f51cc6570mr516839edd.63.1704402538089; Thu, 04 Jan 2024 13:08:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704402538; cv=none; d=google.com; s=arc-20160816; b=S24sTFBZH4x+uct4R3er1pkTBvcoNsXF0RIWcIKnc9wfDC7DT1IHk9jUltbsCgUblO 7YuBr1vlCFXUqAUPGvmM3badvc9kQ1MTMvD09xODDhbuQ0cqf3QLl8+L8KAL+SBxAy1j kUvNhBduc9T6M4Enbu52q6BT1Ajc7+DeRSFO8T5IuedMq6NQuUwGehUxYNZgYN3McyBE UqldqkErJ6Ljo8fsZzRAoMYmoxiX4rby3ciTltkzXyVDUpNEq89GY537NB58P1HIRV+B NXmWsF5jJk0II18kkdq2hX908Gkz6R9keRbRL31im+ltYp8Rg0TB0yfZ0LYEd1OKF3HX WXqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=cOfSf5C8D1sJUiWQ/RlTxPDbyCpmXzMJ+TOzMFfAhf0=; fh=ibj0IwplJyeuAF+X2vqBIpOOEUE9KBluHxouCFj7l2Y=; b=BxFnfp5jk8ELrfAVy48az+J1RoxZyfAuDbmgZY7D9XOK2r1P5lRn/Eh+HGwvAvLKJV /EWxM694dBRBUG03eRMguWApWursWn12Mv44UVGeGiIvFh67iALwGhyNl8PAmfLF03w3 lImyexXge1U2ejfMuWWjT6A/VM5rzeqDYq7If4OPPj8y+PeGWvsRwyXrp71K8/aV2imH x/JPxY6jm1mGpDXmbwCKqRNLhWtj2frOj180cKifENf8EfsYdIaBfBN7uZx4P/t6NK2d C1kenXp7OOqowfMl9P4ouoYvRpy3HeW/rgeUGt4bZROdqX/Dx+U3MMpoECGIMOWFno9z fDkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=jCQNvj5s; spf=pass (google.com: domain of linux-kernel+bounces-17224-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17224-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ec33-20020a0564020d6100b005548822b5d7si99483edb.178.2024.01.04.13.08.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 13:08:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-17224-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=jCQNvj5s; spf=pass (google.com: domain of linux-kernel+bounces-17224-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-17224-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D30541F232E0 for ; Thu, 4 Jan 2024 21:08:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1039F2C6AE; Thu, 4 Jan 2024 21:08:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="jCQNvj5s" X-Original-To: linux-kernel@vger.kernel.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC0B32C191; Thu, 4 Jan 2024 21:08:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Sender:Reply-To:Content-ID:Content-Description; bh=cOfSf5C8D1sJUiWQ/RlTxPDbyCpmXzMJ+TOzMFfAhf0=; b=jCQNvj5sCf7R/im7v+/FGKmHFd oV/yyDZymsV0NB7nHUIa1Tfu5USCEst/mhUYmJ4A/qOCY8VbMCe4o3ZLMajwGhyPE2hnM7jm7e6mH BG4PUsUhUW9nSN1UAOE+WJanlUmvX3hk1lk6PbBpmShVHjlvPxjaZyo5NdO2DnMo7ZvyIjXGgQGH/ 8AvtNCcfeFj2YKC4J4Xt3rTIhvvSmXtqu3OLDmGzhgOHETrxaow6zIXfOoBHdIfQTwej0k4ieFoDd x0VaGGGNX+S1WTOZmWqYlr+g8qIZ58NqznE5NBItJI3CUfhIxf+FxCi5qHNY5283Agksl1V3w28gw Ef8g3WiQ==; Received: from [50.53.46.231] (helo=[192.168.254.15]) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1rLUxJ-00FEgP-0Q; Thu, 04 Jan 2024 21:08:45 +0000 Message-ID: <8fd06532-0ae8-47a7-a4f2-f5b01a25bf93@infradead.org> Date: Thu, 4 Jan 2024 13:08:44 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/5] doc: Improve the description of __folio_mark_dirty Content-Language: en-US To: "Matthew Wilcox (Oracle)" , Jonathan Corbet Cc: linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <20240104163652.3705753-1-willy@infradead.org> <20240104163652.3705753-2-willy@infradead.org> From: Randy Dunlap In-Reply-To: <20240104163652.3705753-2-willy@infradead.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/4/24 08:36, Matthew Wilcox (Oracle) wrote: > I've learned why it's safe to call __folio_mark_dirty() from > mark_buffer_dirty() without holding the folio lock, so update > the description to explain why. > > Signed-off-by: Matthew Wilcox (Oracle) > --- > mm/page-writeback.c | 14 +++++++++----- > 1 file changed, 9 insertions(+), 5 deletions(-) > > diff --git a/mm/page-writeback.c b/mm/page-writeback.c > index cd4e4ae77c40..96da6716cb86 100644 > --- a/mm/page-writeback.c > +++ b/mm/page-writeback.c > @@ -2652,11 +2652,15 @@ void folio_account_cleaned(struct folio *folio, struct bdi_writeback *wb) > * If warn is true, then emit a warning if the folio is not uptodate and has > * not been truncated. > * > - * The caller must hold folio_memcg_lock(). Most callers have the folio > - * locked. A few have the folio blocked from truncation through other > - * means (eg zap_vma_pages() has it mapped and is holding the page table > - * lock). This can also be called from mark_buffer_dirty(), which I > - * cannot prove is always protected against truncate. > + * The caller must hold folio_memcg_lock(). It is the caller's > + * responsibility to prevent the folio from being truncated while > + * this function is in progress, although it may have been truncated > + * before this function is called. Most callers have the folio locked. > + * A few have the folio blocked from truncation through other means (eg preferably s/eg/e.g./ > + * zap_vma_pages() has it mapped and is holding the page table lock). > + * When called from mark_buffer_dirty(), the filesystem should hold a > + * reference to the buffer_head that is being marked dirty, which causes > + * try_to_free_buffers() to fail. > */ > void __folio_mark_dirty(struct folio *folio, struct address_space *mapping, > int warn) -- #Randy