Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7820133rdb; Thu, 4 Jan 2024 08:38:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGcVvfHSC2OxBciaNv4RrnY8ZdIi2tEQ4HVpcLE+UylQKw57439l+7ZsI5KIM0lJwwo2Mhf X-Received: by 2002:a25:dfd7:0:b0:dbd:bd94:38d0 with SMTP id w206-20020a25dfd7000000b00dbdbd9438d0mr668443ybg.72.1704386304074; Thu, 04 Jan 2024 08:38:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704386304; cv=none; d=google.com; s=arc-20160816; b=GuRvptk0ATpbctnpGHcCtVKS9gRKbFi886/O0f+mvr1Dr7akn5JxY2UWM5KewHVH/S dDMDre59v14f2YXgTOMWnT737Hkwfa/eeSAiBnUQ4rj123d53SxunMJct/UduOHYPkh+ y0mtEUYmI8QWnSEXhM5Wr9E06usct+uqNlt9MiSISOLwprpcAHd9AvgrPPcol4Qe3wHc 1jUx9UOlkDv+5jICCQnCxvVQOdCat1qrEwS6hZlm1Ri++2XX49o3zXR2q4vUlkV+pmJr QecouGQwCRqS8SvGGbolJmdfNhIvcXDwR4yyfDLzg9e/5UlBp863ISeVR3rG1dc/Vx+E muuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=H86wXih4qa5SRCLfR55+imGW3Jd0bnKvhtj/OW2JOWE=; fh=C1THyYX8mZv7/wM+MHV1ZUcnQSQiZbUrxk0HRhdecS4=; b=VmEeew6LvmI6jYIfVUX7cCe9kO6b1Bfr2KzlW2gHNMdxihCZvHfwh+S2zB9yjsczLQ 6wyPCd+MxY7mtudfNje6GaJbJW71GhFs7E8DF52qpfiqkF8KPU36VA15wXCTQYqPzy06 6opBpXrS6NUZAZLRy1nbkdC3uEiVTFiyYDJOe5WSac9oXSl3d5z5vO8ygqA0sODqIceT c5YE1cQ+ZPrNZSo9VoxMZchwWT8K3phdaFRYwv8WWcBiuqh89IJctog/L6BCwUMVfQ/d scrwbPsYhm38hdid54FwII6Y5BVESTsDxXDUjQXSSEmlHcAjuc0sgLPyfcK6FlYllYFy 6g0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=aVM70ztc; spf=pass (google.com: domain of linux-kernel+bounces-16945-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16945-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p6-20020a056102124600b00466fea32518si2400987vsg.649.2024.01.04.08.38.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 08:38:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16945-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=aVM70ztc; spf=pass (google.com: domain of linux-kernel+bounces-16945-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16945-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C81991C22161 for ; Thu, 4 Jan 2024 16:38:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AD8828DDA; Thu, 4 Jan 2024 16:37:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="aVM70ztc" X-Original-To: linux-kernel@vger.kernel.org Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 13AF828694; Thu, 4 Jan 2024 16:37:01 +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=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=H86wXih4qa5SRCLfR55+imGW3Jd0bnKvhtj/OW2JOWE=; b=aVM70ztcUrn94i15DnCUDthI4d KNsTTNkSTOp8OmVXtJB17jfGF+2V4xXDYn9eL4TjV8MVsoHCI6izhlVJIfuMIfvH1Na1WOPLVzo1A uY2thyCQuegrtm24LwksywTxqQ0PUJ9/F3S1e7qXKLzIwKq+iearA0IHhLwvUAG4syMvSc+n6WSAm 8j05bWWmx/rWzu6qco3pxh6gepExpRYM4aw5Of4bdao/vfANubqFqaYy5qksmHCbPnSbKq3+ZMSOe 501pcKOqjI9gHjx+x6MbqFCJmDvOLtEMUDbMT7QZUfS4Nm2Wr8bjHFcwaDu1XSmr7JgaQnYM3uNVL 4JLvimvw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rLQiE-00FY2R-H5; Thu, 04 Jan 2024 16:36:54 +0000 From: "Matthew Wilcox (Oracle)" To: Jonathan Corbet Cc: "Matthew Wilcox (Oracle)" , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] doc: Improve the description of __folio_mark_dirty Date: Thu, 4 Jan 2024 16:36:48 +0000 Message-Id: <20240104163652.3705753-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240104163652.3705753-1-willy@infradead.org> References: <20240104163652.3705753-1-willy@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 + * 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) -- 2.43.0