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 27B45C021A9 for ; Mon, 17 Feb 2025 17:58:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B261D28007B; Mon, 17 Feb 2025 12:58:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AAED8280078; Mon, 17 Feb 2025 12:58:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94FE428007B; Mon, 17 Feb 2025 12:58:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 70CB4280078 for ; Mon, 17 Feb 2025 12:58:19 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E03D4C0AFB for ; Mon, 17 Feb 2025 17:58:18 +0000 (UTC) X-FDA: 83130195876.10.7A9E6CD Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf22.hostedemail.com (Postfix) with ESMTP id 16D36C000E for ; Mon, 17 Feb 2025 17:58:15 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="c/g9dTBH"; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1739815097; a=rsa-sha256; cv=none; b=MsX3iKRQT0uGw5Qpn20Wj+YyHjzRqLXjQUnpgI5qLaAj7oNqypF8A34m3mEJzBaDToM+XU xZJLBq0vgp9COV0EBmiztS0iPKY2nCNyhQF0bm32MJR8F7NxJ1YZIruDgtkguOweCne84J nBdNLdclUjqE91KKJ2lTlQN0Iy9Wejc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="c/g9dTBH"; spf=none (imf22.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1739815097; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=j+FzReHu2D29+ormcX1qLAUNVPWvk3sDBenwW2uljpI=; b=tKSTzRtBEG3FnmGB0XMbn2LfTXb1Gj2xkjtfvClzJwt40kAS9ZzOVT1dUz6/MPuvIBEyCZ qHOVZ/eOqpPx59qwFjAGWyqC+oP3itWrKjYe/Sa9XzqihOfdOO9W2kTkyUJlQNZW4jQf1j /gARdA13cMsCj0/DBe/3IU7R5e9ueDE= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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; bh=j+FzReHu2D29+ormcX1qLAUNVPWvk3sDBenwW2uljpI=; b=c/g9dTBHbqKOdkGcQONgiC74/X hTGvJzDd5KIPqKrOHrvLrMI11aWIFp7fWBoTdRcO+r7+uNzeAQ6rdxPaMsTyElPTfKv0jzKs7CEgE HpnbNLstSeXQVzzd0e7pML95czGQ0wGt4HdLw+fmr99dluOU91Mws72WrCaGMgA+yRM2k6tae66sA JzJistXqLkxmfE7tletLM8gQd8mZSRe9KNnPigUCOWahASqh6ko9Nq/E4D+Pj7GJUmyRxpFbd6NY6 OHX+d4tre10IjPwag2867if4izzYjCGyHiIVaPnUmorl/WqlpRvylQ4GF5ndkH3feNwRj7qmyffGw mgSN2vPQ==; Received: from willy by casper.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tk5Nk-00000001k7S-0p68; Mon, 17 Feb 2025 17:58:12 +0000 Date: Mon, 17 Feb 2025 17:58:12 +0000 From: Matthew Wilcox To: Colin Ian King Cc: Andrew Morton , linux-mm@kvack.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][next] mm/mincore: improve performance by adding an unlikely hint Message-ID: References: <20250217170934.457266-1-colin.i.king@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250217170934.457266-1-colin.i.king@gmail.com> X-Rspamd-Queue-Id: 16D36C000E X-Stat-Signature: iadn37o8pp615qj76x9u54fkqm7yay4f X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1739815095-196252 X-HE-Meta: U2FsdGVkX19kq4zBZV4BUCGVJJoRsg+rdI7GQKCpFpSI+1Ee3M/DuNpAEg+W4/iad45Q8fIahc4s1fXELDCCg5W4skepQFLxukxMH21qhZo3cuJlAJFt3R4xBj1MdRg+eVvSP+DOQxqx0AwJbybQ77vAZ7Fw84gCJ3Rj13WomZ03NapLTmCn+wAin96ZLGraO215lDotS3t8F6vfENuZrEwsjqdU1jLu1tUATH0H70U9+wh8x5AJbnqsu4ZqRIlwtEc49iNLlSd2X5zsHZo3A4QkTiip+RNB3AqCnAAZrx2KhamYh+/kL1R4ZVud7lbbW3OQfT6u2yUKpT3L6nj+TEv2v8sY+Tcc+fqFLpJuLTZvgZjWkl81k1e9vwnRAra7CE7b+IEKwPJu9TfpEnRQY5OMx/2py/oenJIX1NpIJPmqKuN2shtqhVSy0n/1HuRvg+5TbfDgMsQQEo7i239NY2ccfq83EnVlMmMzIfcDCpOhF94Slsp+1SKqITkPNBGtT90IAEZLLTZL6DiQUgCv2aMohRVgW3JxJY2qzGNMu6KZvRAxuaC59+ddIDxb0zvnVhtVMg/WAnKzawha0asgGVwKZ0Pcr1DVmniIR12yP7jMoimn7H+XYFJ3O5DHsioqJSuTACrrhiJ6ZO9oarBMvXFpQv4YQo+3T8VqFuui8rovYayHOMu+l2fm0XqtgGwXEbStltHb+Nz9YsJKt8Rh4WDgzCwViQ1/FZocdFIKwWwRstpXiJSzKjY163C68MMHWPXMI/8wLY1m6lao2VG1qhBlw2l/6TouxnVVAalS2eAWcTpN/h1ELRYPmc/XPtf+fOiUaiMjJlCzps62M/4h9bbMcEW76CWqHuQ/vf5pOSu+YR8ca2E13Bmyeb544rcI/y0GunDqIpUZ2HVWF4EeywDe2KoAl1nbxpuns2rQizvYHLI20QA43EnDscLlUAUOe8UrpvUuFJrN9VE5tml 37LiJBzo AJq208zLPVmEkaOfM8Lx9oSxeqOBxCrlf19zMSDQQKr7QdChRPzZdZnSAWCfwCp5pESUpcHkcKqlTtg4tEb7fUcdDTUhqxoAKjKeO4TUjUog/VnZKGtFr5IYurxNibRkwFDcou8K8k0AkOVbSbwmI5RGFNMpiwjZpF9MCevByVYz0ClvJNFQVFNWYMLjcn4Uvw7WRlzS19V1n9bmV7+4zlU2icU1Q1G9aW/Jl9CkT3+aCjq8e/B+RGm/A/uM6g1+ROMZQJWeJvjIP4fgJm1cUa+vV8SdW4CjbTRY9TKAcogxyW1zJn5qFkMD4D4QFFbKGi1l5 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 Mon, Feb 17, 2025 at 05:09:34PM +0000, Colin Ian King wrote: > Adding an unlikely() hint on the masked start comparison error > return path improves run-time performance of the mincore system call. > > Benchmarking on an i9-12900 shows an improvement of 7ns on mincore calls > on a 256KB mmap'd region where 50% of the pages we resident. > > Results based on running 20 tests with turbo disabled (to reduce > clock freq turbo changes), with 10 second run per test and comparing > the number of mincores calls per second. The % standard deviation of > the 20 tests was ~0.10%, so results are reliable. I think you've elided _just_ enough information here that nobody can judge whether your stats skills are any good ;-) You've told us 7ns (per call, presumably) and you've told us 0.10% standard deviation, but you haven't told us how long the syscall takes, so nobody can tell whether 7ns is within 0.10% or not ;-) > Signed-off-by: Colin Ian King > --- > mm/mincore.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/mincore.c b/mm/mincore.c > index d6bd19e520fc..832f29f46767 100644 > --- a/mm/mincore.c > +++ b/mm/mincore.c > @@ -239,7 +239,7 @@ SYSCALL_DEFINE3(mincore, unsigned long, start, size_t, len, > start = untagged_addr(start); > > /* Check the start address: needs to be page-aligned.. */ > - if (start & ~PAGE_MASK) > + if (unlikely(start & ~PAGE_MASK)) > return -EINVAL; We might get even more advantage by moving the EINVAL test before untagged_addr() since we know that the tags are all in the high bits and we don't need to have the test be dependent on the previous arithmetic.