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 shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 679DBCD4F54 for ; Tue, 19 May 2026 22:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kernelnewbies.org; s=mail; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Cc: In-Reply-To:MIME-Version:References:Message-ID:Subject:To:From:Date:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zFtGausJf/LcNFftJjtaLH9ggeZp4mzEiQP/m1bwg8Q=; b=kF0W1Fu06sGcgh8IrXKuK2zeJK dp/pHo+IaXyl+MXUDGqGzCTds8RNTVyvHTvU/XHv5CJWUe3NOTK6Mz7Sa3ulEOV45jQsFQqh5Oxf8 Ro2ogDwqeKMWfSwTe5KLFMiWQF5z1trLxwi7YMRSoEctDGsRrBLQS+kyf0hbB2WP6ltZYrqaRxOIH 39fgW4JHw3O78tg6ovNRHUEH7CGhWcN3dakZIk2DOQcwi9jvJYXHp0Hli8Glz0N9ckr7pBPHj3+Rh 6HvX7RYwaCPDjhITGJsr5Ru1oIjahFCNQjtUv6g/2Gyz6x3k1g9HWTW1IgW9XtZIrdBLs/X+ovvDw 5yffHApQ==; Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.97.1) (envelope-from ) id 1wPT9D-000000005n6-3TC2; Tue, 19 May 2026 18:42:47 -0400 Received: from nyc3000-r.dnsiaas.com ([96.47.167.18]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.97.1) (envelope-from ) id 1wPT9C-000000005mz-0Yjd for kernelnewbies@kernelnewbies.org; Tue, 19 May 2026 18:42:46 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=agatha.dev; s=default; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=90adkjBQCidA1G31mHsVJYfRT2JM9CMFjChPs2mCYJQ=; b=oWWbbmOt9s+7QBkk1LuoSB04lT dmagBvb9eExBOD0dASYV/t1wIqEU+nSYlmdbSLRvGtWxAaCJhA1jb7jZT0p//Bg2MHO33g8qEro3I /nKDtTw9Eso2npnsabYuQqF+WvJ+QfPjXuzXuPdyiXeVUN7UzsYC54CCYkziJQBdsji9kC/5N/DjJ jJrGSU1KHOF5WOlN4o8S3PIeF8T4QogVN61+R6U/rUken1F7/aKbBhvCYvf27frFExGGzKUDS5325 T8JMVCiZfP659L4BXKUa4bEs9tNGuDvyNEcKWYWmC0AkWX/ok96ZuT+jgq9Yw2EAMcJbHwclnf/TF CS8btjoA==; Received: from [170.254.153.141] (port=15559 helo=guidai) by nyc3000-r.dnsiaas.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.99.2) (envelope-from ) id 1wPT9A-00000003ieU-2WfQ; Tue, 19 May 2026 18:42:43 -0400 Date: Tue, 19 May 2026 19:42:39 -0300 From: Agatha Isabelle Moreira To: shuo chen <1289151713@qq.com> Subject: Re: why don't unlock_buffer call directly clear_and_wake_up_bit? Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - nyc3000-r.dnsiaas.com X-AntiAbuse: Original Domain - kernelnewbies.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - agatha.dev X-Get-Message-Sender-Via: nyc3000-r.dnsiaas.com: authenticated_id: me@agatha.dev X-Authenticated-Sender: nyc3000-r.dnsiaas.com: me@agatha.dev X-Source: X-Source-Args: X-Source-Dir: Cc: kernelnewbies@kernelnewbies.org X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org On Sat, Mar 21, 2026 at 07:54:39AM +0000, shuo chen wrote: > The unlock_buffer and clear_and_wake_up_bit call same the three function in the same sequence: > 1.clear_bit_unlock > 2.smp_mb__after_atomic > 3.wake_up_bit > > So why don't unlock_buffer write the fllowing: > void unlock_buffer(struct buffer_head *bh) > { > clear_and_wake_up_bit(BH_Lock,&bh->b_state); > } Probably not the answer you want, but the `unlock_buffer()` has been written the way it is back in `fc9b52cd8f5f4`, in 2008. And the `clear_and_wake_up_bit()` function has been introduced only in `8236b0ae31c83`, in 2018 (10 years later). So, the root answer to your question is: the function didn't exist to be used back then. Judging from the commit message at `8236b0ae31c83` I would make the educated guess that they are semantically identical, but I don't have enough knowledge to make such a claim firmly. Maybe the semantics is the same, order doesn't matter and everyone just missed it. But maybe nobody changed because order changes semantics, I don't know. --- Sincerely, Agatha Isabelle Moreira C Developer | agatha.dev Sourcehut: https://sr.ht/~devlavender/ _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies