From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 C6EC43C3C13 for ; Tue, 16 Jun 2026 03:13:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781579615; cv=none; b=Pb8MyHAb1wmiE3kFEd0agLoEANMRbl4MOZUQEeQaDo2Wy9E6VkVA7cNXSR4puNIrIZ1472jdnNY9luKRRGjTxV/MOxP7Oc6Wk5cb5RqWzRo8j2MwV7YZZSc3/45dkBc7nLOtrNTr/WTdHzZLcZneuvXcBgpjfmDARvFmJdEUVS8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781579615; c=relaxed/simple; bh=uLKgiKEQNHNuuJhGlz5OrbNoZJsvZzf5odfnMAkTkEU=; h=Message-ID:Date:MIME-Version:Cc:Subject:To:References:From: In-Reply-To:Content-Type; b=liLgKpu/eGdZHVkz1i3tFHUqsgQLDsN8Wj2v6IKPrJYLHygk4UCZwfHchq0+2/9aHkP+Fb5wZI3F4DheY6nL4T+70nwQBgyjUGLjb3pgueIM05n/FBpVQA0m3RwpAekEGorNE0ep7e4ckEq1lYf/4RRz1WWeQgsca3T+CpfMzP8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VBZp+q7c; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VBZp+q7c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E168D1F00A3A; Tue, 16 Jun 2026 03:13:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781579614; bh=6SzLj0H5lE1aSt8vA/tXV7KwiKEOW7kAr1Sy+xAL6UU=; h=Date:Cc:Subject:To:References:From:In-Reply-To; b=VBZp+q7cLntxQLWUlgn8kfGaZXaCvFo7gisQUAj3YEfJ1SUUDo2TXxsbbBE30T7Zb JBcS6OUl6xvchbErPSOAs0RocrBWCorC/SOf5B3oAS7sPp/Xt+lyiaxPGxj6Fq3UI4 bxwDSQU3Nw4w5WdWow8f19zhm6F05+GMgsFgt4vOPJnDR0w//H/akhlzUz9WxUjYgc cxJBdrgIbErN5t1Dz7oa5sHnkOa7tdwf1KJh0VKO+cZDvW2Vd6zmKkSOe+H+m+zqsU 0o9QQbZbXAFzVLqWi+AUK1a2UKOM6olyjKjEkpvN0tjlRUteTBcRAXKwtRt1/aXY2Q Mx45Sh3qtbI1Q== Message-ID: <8810431d-8364-44d6-bac5-d879e67529b2@kernel.org> Date: Tue, 16 Jun 2026 11:13:30 +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 Cc: chao@kernel.org, geoo115@gmail.com, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, qiwenjie@xiaomi.com Subject: Re: [PATCH v3] f2fs: use post-decrement count for cp_wait wakeup To: Wenjie Qi , jaegeuk@kernel.org References: <20260616014742.67236-1-qiwenjie@xiaomi.com> Content-Language: en-US From: Chao Yu In-Reply-To: <20260616014742.67236-1-qiwenjie@xiaomi.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 6/16/26 09:47, Wenjie Qi wrote: > f2fs_write_end_io() decrements the writeback page counter and then > reads it again with get_pages() to decide whether the last > F2FS_WB_CP_DATA completion should wake cp_wait. > > Use atomic_dec_return() for F2FS_WB_CP_DATA completions so the wakeup > decision is made from the value produced by the decrement itself. Keep > the existing dec_page_count() path for other writeback counters. > Missing Fixes and Cc lines? Otherwise it looks good to me. Thanks > Signed-off-by: Wenjie Qi > --- > Changes in v3: > - Drop the waitqueue protocol change from v2. > - Use atomic_dec_return() directly for F2FS_WB_CP_DATA and wake cp_wait > when the returned count reaches zero. > > fs/f2fs/data.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index d83a21998ec2..58d23eb74ec2 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -392,15 +392,17 @@ static void f2fs_write_end_io(struct bio *bio) > if (f2fs_in_warm_node_list(folio)) > f2fs_del_fsync_node_entry(sbi, folio); > > - dec_page_count(sbi, type); > - > /* > * we should access sbi before folio_end_writeback() to > * avoid racing w/ kill_f2fs_super() > */ > - if (type == F2FS_WB_CP_DATA && !get_pages(sbi, type) && > - wq_has_sleeper(&sbi->cp_wait)) > - wake_up(&sbi->cp_wait); > + if (type == F2FS_WB_CP_DATA) { > + if (!atomic_dec_return(&sbi->nr_pages[type]) && > + wq_has_sleeper(&sbi->cp_wait)) > + wake_up(&sbi->cp_wait); > + } else { > + dec_page_count(sbi, type); > + } > > folio_clear_f2fs_gcing(folio); > folio_end_writeback(folio);