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 869D1C10DC1 for ; Mon, 4 Dec 2023 15:28:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 174386B0173; Mon, 4 Dec 2023 10:28:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 124186B017C; Mon, 4 Dec 2023 10:28:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F04466B017F; Mon, 4 Dec 2023 10:28:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id DDFB76B0173 for ; Mon, 4 Dec 2023 10:28:38 -0500 (EST) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id B26761A0146 for ; Mon, 4 Dec 2023 15:28:38 +0000 (UTC) X-FDA: 81529517916.17.FB0AE00 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf08.hostedemail.com (Postfix) with ESMTP id 4E6A0160008 for ; Mon, 4 Dec 2023 15:28:35 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=KefSqzuf; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=PogRzCcH; dmarc=none; spf=pass (imf08.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701703715; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zhM9TspgCLXE7hNDqvbME/NvDDvk0vZddm+UOV6znaw=; b=NOl5uo2zVYoyGU1FN5myc++u/onFQBIUmcxa3zk57ZmveNecNWIxxkC8a5FxYdS4YOLx0e FD0Jhbl7gh7ZZtv3lEdkFhJl+LTWpZOLrBC/K8GkP2MP8WCU5SQtFJ2wzqzaXqe/ua8sym iNyHgIaUlY7Ml3asCd/O63au9OCvgWk= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=KefSqzuf; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=PogRzCcH; dmarc=none; spf=pass (imf08.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701703715; a=rsa-sha256; cv=none; b=fjqFoBFCA8xEZU9aoQ/NOMDDTUDmTMVHyPRgqKsgluIljMWfAGHlivlGd3LDJLeTEE5PDj hhuGqjjMPsZM/01ToNLeC0cHWsD35ZeYZou3leuOisReVE4pqO/fZzVAOYpZ4Oj40u6nE8 w6Om6osSB4tu5xXYbFyobWreZBFqnR8= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 398411F8B8; Mon, 4 Dec 2023 15:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1701703713; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zhM9TspgCLXE7hNDqvbME/NvDDvk0vZddm+UOV6znaw=; b=KefSqzufCmAoYTnhCiQM/HiSQZ039lAtfkXe/6RKCrH3AJXh+LU4LFDOpNmyuhL21NdpzF NjZiIAmGFw/XfwrDr+Zr4vagh3NNtA3FplK5ALw9emEjLh8yZ/PPa1bR1auNT5cT5Vu8pn Kidjuc+z73TDVLb2sL1IsP/E765Pyd0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1701703713; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zhM9TspgCLXE7hNDqvbME/NvDDvk0vZddm+UOV6znaw=; b=PogRzCcH5uvyKwfduvxa689E9cTOR2CbtoXvd2OdVJ41jWRFQwoZKwJT/L3PU4VmXJV0qM SPopx6LZY4gfLWDw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 286CC1398A; Mon, 4 Dec 2023 15:28:33 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id btN1CSHwbWUkVAAAD6G6ig (envelope-from ); Mon, 04 Dec 2023 15:28:33 +0000 Message-ID: Date: Mon, 4 Dec 2023 16:28:32 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [PATCH] mm/rmap: Fix misplaced parenthesis of a likely() Content-Language: en-US To: Steven Rostedt , LKML , linux-mm@kvack.org Cc: David Hildenbrand , Andrew Morton References: <20231201145936.5ddfdb50@gandalf.local.home> From: Vlastimil Babka In-Reply-To: <20231201145936.5ddfdb50@gandalf.local.home> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4E6A0160008 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: yjp1s4m5cjruz63a6b1dtqn1xmn1c575 X-HE-Tag: 1701703715-53798 X-HE-Meta: U2FsdGVkX18iEZabENGkh3dqXVHrdUFJBnCpdqVcOPzq62tNlsJWuXxp03fON1ntSSzPJyN+WdyxHC7yx974Gx4fyJVvx1c7aMr0pqmj7cauTUID0h/XP+ni6M4aIPIB7pKsaCfxjtditQ/KhmQAAtRoYRKEglLnpZjwyTwP6mwL0tA0DX1lAy2pXmBckFyf63/LBhb7IY6ur7eql7A/bqdLnDeDoIgPdQr4p07bYCvuJNcBGkLmPICVgbW4UlBq9IAGQ6iAaNu6jl+Gk89PslVYPGuAmjZ4n2vYSwZBvM7wM7A9bzQ+OFQNC8zvkaEwtsDa6k4cmBzt6qUiWRSYuVqd1C5JGaAbWANHkvkvHvGkKhDthDUE6m11OCVdTFNl/z9VJokd5tnxmncvFfkDOmMi0LDlRQ8EpXdbdgVInNVEHBaiyTZZVEEyj6ZxSiwCA+A6sDYql5PKopTr29YOL/LTzU2MLeXnPRTj0nkUBFn3FXpER1Z0CBD/XJotw0ngAyP1NZ1dRnEUQVDTr1dhj788P8vb4NvpWLqzqVneVBEvp3bvNISEZj3W0qwbHb1iUr/Cs+R5mvxL72VlMIyLHdT+WK6Jud4lMhFY9Z3VELSYv0RgpaadfdDDEYFMXB+qSC5zrHPtbKlVQIerf55FVH4CWcjE8x1ItFY5SoKj40665kCwGJa0m5JfYdJx6akcgGvFYxhpCIDlg5R0+u3uWZCLd4yVv91hqNim8TIzF7l0EvLeQB59t2eppv1NmfZc6p92Y8vciL6ds36xXLVVBfkRgbylelBgrpmto6eWEIc0gDyNmA95JYV7NmjkhwDEJoFspqOynsTq9ELpYPQ5rkhU0L6UCUa+BbKynlD0mXBm7/r4DOHb0BYwlrhttg3sTKwgkmGITISUZKh7gRaB/KzGs37XG0eYy1ZVRkN8WaQphMCpCuxzc5BXN0AfTYGTSUtodMl+UczxNVx0Uq2 T5JgHmVB oScbgC4woH0dXxGMvLyGT3St9NBjkVnZALp8x/HLPzDnjOjxkvfZdzFUEAuWxjVglt5qznQkuSgsveUwCb7iNUWz1+Buy9Pkdfz//HiZckhulRZUM65vPYXMOsIMzza5vbfTpwSraho/EgEM+NUYqfh2p+wIMlRIl+Q9Ci3sh53u5Z7WefRnj1kJyczxPqGHw5D0+ozkwVppj2xZMDSsnhmMUmFCDVl84ahtXYvUR7f1OHHnGiM9upEPBXVbGjdiutZiFoFuZtkNeV9etESew+5nCn1oBN7D3jXzIuhSz91kMYCAuOB9iSh73/LOAAhTGPA9Sbqpklwmns6Vn+2VZrof2FQ== 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: List-Subscribe: List-Unsubscribe: On 12/1/23 20:59, Steven Rostedt wrote: > From: Steven Rostedt (Google) > > Running my yearly branch profiler to see where likely/unlikely annotation > may be added or removed, I discovered this: > > correct incorrect % Function File Line > ------- --------- - -------- ---- ---- > 0 457918 100 page_try_dup_anon_rmap rmap.h 264 > [..] > 458021 0 0 page_try_dup_anon_rmap rmap.h 265 > > I thought it was interesting that line 264 of rmap.h had a 100% incorrect > annotation, but the line directly below it was 100% correct. Looking at the > code: > > if (likely(!is_device_private_page(page) && > unlikely(page_needs_cow_for_dma(vma, page)))) > > It didn't make sense. The "likely()" was around the entire if statement > (not just the "!is_device_private_page(page)"), which also included the > "unlikely()" portion of that if condition. > > If the unlikely portion is unlikely to be true, that would make the entire > if condition unlikely to be true, so it made no sense at all to say the > entire if condition is true. > > What is more likely to be likely is just the first part of the if statement > before the && operation. It's likely to be a misplaced parenthesis. And > after making the if condition broken into a likely() && unlikely(), both > now appear to be correct! > > Cc: stable@vger.kernel.org > Fixes:fb3d824d1a46c ("mm/rmap: split page_dup_rmap() into page_dup_file_rmap() and page_try_dup_anon_rmap()") > Signed-off-by: Steven Rostedt (Google) Acked-by: Vlastimil Babka Pragmatically speaking, stable maintainers haven't been following the stable rules for a long time, and a commit with Fixes and without Cc: stable is often backported on the assumption people forget Cc: stable, and "Fixes:" implies there's a bug to fix, and it's good to have bugs fixed in stable... We have (repeatedly...) had mm extempted from this and Cc: stable is required, which is good. So if Steven thinks there are reasons to backport, then I'd rather let him keep the Cc: stable, instead of this later becoming an argument to question the mm extemption again :) > --- > diff --git a/include/linux/rmap.h b/include/linux/rmap.h > index b26fe858fd44..3c2fc291b071 100644 > --- a/include/linux/rmap.h > +++ b/include/linux/rmap.h > @@ -261,8 +261,8 @@ static inline int page_try_dup_anon_rmap(struct page *page, bool compound, > * guarantee the pinned page won't be randomly replaced in the > * future on write faults. > */ > - if (likely(!is_device_private_page(page) && > - unlikely(page_needs_cow_for_dma(vma, page)))) > + if (likely(!is_device_private_page(page)) && > + unlikely(page_needs_cow_for_dma(vma, page))) > return -EBUSY; > > ClearPageAnonExclusive(page);