Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2784192rdb; Mon, 4 Dec 2023 07:28:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZN1L5BJHRr2NUj2hjyhgpEdXXAqk7HLn3rsAd51UOImABaYWWa0jjMnShZl+0cpxCasXn X-Received: by 2002:a17:90a:ad83:b0:286:6cc1:5fc4 with SMTP id s3-20020a17090aad8300b002866cc15fc4mr1452403pjq.71.1701703730179; Mon, 04 Dec 2023 07:28:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701703730; cv=none; d=google.com; s=arc-20160816; b=FPQMfyKe/GI5Ffg2tfZVKvFheTUW/D9PoktPnEAX5fqmf5Edbf0GIndreNDv6K93mJ wC+XWsl3IVwZpGQ1KZsQ0QMHp5gJdHuFCfQ8z6AdmKAAhYjQHe30hOnaMnI9hg8Ki/36 MHVYLVSZO6pabxCcuTMurSX/2QYl27eXAzZH8/bv6WOPrvnEz7yHgST4xqTn12j3n8YP pI9PxNjWnwEDLZq0F6u42JqCTkjprsNZd2xdLbVwu7d0KHsouAf53Lm0JaEypzZhlDii tN0AEFSs4jVB+4o4DcGf3q6/IvEX4pib3vejOpwoZ4eSeANKgLLB7xgKYFzp/nOM3bwc uKDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=zhM9TspgCLXE7hNDqvbME/NvDDvk0vZddm+UOV6znaw=; fh=6Jr4W+ESnWTofPWOp057WR+7snYwjXGTKRr/5rvxNCs=; b=DcX1CMAPIHHX+pd+MJm3QU2fV6TGZQ3izmmWYBc4ylNro31cft9VTCYDud7nUrdqDn k2MyjkvOe5eaiPg7tgIjaHqxK0AGlJvgB2M1+1hNCytmqeLqpGSLULCE3QkT+YVkT/hY 4q4t5xQ1J3WyRvcquRkKJE6AmF0t5AflRggplcyYHldyKSUQOy/8iSJZF6qv5EfijJEi 08De8qMkTKY2DDu6wdg94pOXVjYYYJ30/q9iqZ48KcupoN2jrdaFuX46t8dFHNFrDmJU Op4WVTySapwqzXT4MwP2C65kACHRqnUuXpMyGzp5IiUSHlOxclSSbtz4moxsRu5B0ngh 4bxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=KefSqzuf; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id ce9-20020a17090aff0900b00286b48a6226si1710044pjb.89.2023.12.04.07.28.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 07:28:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=KefSqzuf; dkim=neutral (no key) header.i=@suse.cz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id DA29B804E7AD; Mon, 4 Dec 2023 07:28:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234486AbjLDP2a (ORCPT + 99 others); Mon, 4 Dec 2023 10:28:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234215AbjLDP22 (ORCPT ); Mon, 4 Dec 2023 10:28:28 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2a07:de40:b251:101:10:150:64:2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD39DC0 for ; Mon, 4 Dec 2023 07:28:34 -0800 (PST) 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 Authentication-Results: smtp-out2.suse.de; none X-Spam-Level: X-Spam-Score: -4.10 X-Spamd-Result: default: False [-4.10 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; BAYES_HAM(-3.00)[100.00%]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 07:28:49 -0800 (PST) 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);