From patchwork Thu Feb 16 06:47:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 13142667 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 BD2E3C61DA4 for ; Thu, 16 Feb 2023 06:47:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3C0CC6B0073; Thu, 16 Feb 2023 01:47:41 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 370F56B0074; Thu, 16 Feb 2023 01:47:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2389D6B0078; Thu, 16 Feb 2023 01:47:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 115FC6B0073 for ; Thu, 16 Feb 2023 01:47:41 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D07EB1410FB for ; Thu, 16 Feb 2023 06:47:40 +0000 (UTC) X-FDA: 80472224280.04.D43A883 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf02.hostedemail.com (Postfix) with ESMTP id 399268000C for ; Thu, 16 Feb 2023 06:47:39 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="OHpT13/S"; spf=pass (imf02.hostedemail.com: domain of 3idHtYwMKCAozmmqyyqvo.mywvsx47-wwu5kmu.y1q@flex--pcc.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3idHtYwMKCAozmmqyyqvo.mywvsx47-wwu5kmu.y1q@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676530059; a=rsa-sha256; cv=none; b=7CB/GTQv8HMrw1m8id+r0cDsPBd6g7FE7ZbchxhMe80pZC4TYZ4GNcwtQaJX//dTWPv/cR MEImQae1ahL8tx5CNCydXbeR6tG+abmI1Y42eQzsrFLMtjRBrJvAA9pGT7tXCUzUoFGiIp zamtHLroGiCjhAOY7naOv1YCvqTNPBg= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="OHpT13/S"; spf=pass (imf02.hostedemail.com: domain of 3idHtYwMKCAozmmqyyqvo.mywvsx47-wwu5kmu.y1q@flex--pcc.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3idHtYwMKCAozmmqyyqvo.mywvsx47-wwu5kmu.y1q@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676530059; 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: references:dkim-signature; bh=U1KTvO9eh7af24NgSabBS4dGCCNbjIjt0zmjrEHKiTs=; b=lxKz5TbA7opsBkN428yjO1r1E/DCNlMtDshNafpRv74Uw6ZxAh3g41LqlTGDYoVlZev1/3 Pnd94fXsUl3ewnj0b6L2ck1JwYLd5Psm+BCsQC1Pw64kU+s/bXK5jEZ+EKsAL5NJBVkcha Nk1u3kpgTzoKgs1AAUFelminORcDi78= Received: by mail-yb1-f201.google.com with SMTP id e191-20020a2537c8000000b009433a21be0dso1017239yba.19 for ; Wed, 15 Feb 2023 22:47:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=U1KTvO9eh7af24NgSabBS4dGCCNbjIjt0zmjrEHKiTs=; b=OHpT13/ShK01bHTTiGQpOkxVzV8pA3jZiyFv/AU7X6UIDvLl5ByZWPtKuDj3X+EE+S RzFRVyIIjuvXN6u1ZFToZAhJW7XXC2WXjq2RwiiMJXPsBZs8orU7PqhCoR1oUDNRykJ+ nOKa8JSENsgplBgLDfCa2eMMx5J+hvXBV+mhZC3EDxr7H/sT6+8xYWkCDrx5oNsMsn2g i0BfVkorO2EeIY2ab/d0ZuS3jXQMXsEoux6miWDJeducQUhtFKts/moIZlqF4EBrWcDT DWXosukzjzzgFqODPgTWiLOmJ/Joc9nHPD4osSLqhWsGv8A/ui34v1LAteypKVjRfRvA niOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=U1KTvO9eh7af24NgSabBS4dGCCNbjIjt0zmjrEHKiTs=; b=JTWy9UqQEqb0PHscyFbBR0fLrUMY3G1gA3pAaWQSNvBLnQk6m/uzp0FUeVsBwGABgx RuvsqjrsnUfM30sArFAT3+Vwhb/sC8vxU/lWqsIoFCYc3AE1mDgpD3hLJyZexAWmklXi SrskPPuDYeC7/qG2+WqSpNUDVVJdTLPsRBp7LZQa8Y33QcX9t8eqjeiKiOssnTVBS554 DXtjQZmvpjTCNYbK8Sl1pWkFJtb+xgQTFYZsBnFZ5fI4H0aFjwQXIcRxx0Vf13v74vQd 7tA8RlWkpZKluPUVWPCjjfU64yUjz/0r8U047ajV9dcQrobS9I1uMkXu8uA3WrLTg6+b ta9A== X-Gm-Message-State: AO0yUKV5m12ZW49Ddex2lmUGEnyB7XLShygb0Caq6GzPwzPWnaxH3k9/ iWYImlA2cUjxrsDcvspTtn/GTuc= X-Google-Smtp-Source: AK7set8IHohEy2xJNi2KgXsl8cXGjRbX0js9EYeWNv5hFjkZjqSfCNnZOGUUuUVDJoFYdw0moydtUWU= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2d3:205:9dcb:3224:f941:1aad]) (user=pcc job=sendgmr) by 2002:a05:6902:13c6:b0:8da:3163:224 with SMTP id y6-20020a05690213c600b008da31630224mr9ybu.0.1676530057864; Wed, 15 Feb 2023 22:47:37 -0800 (PST) Date: Wed, 15 Feb 2023 22:47:26 -0800 Message-Id: <20230216064726.2724268-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.39.1.581.gbfd45094c4-goog Subject: [PATCH] kasan: call clear_page with a match-all tag instead of changing page tag From: Peter Collingbourne To: catalin.marinas@arm.com, andreyknvl@gmail.com Cc: Peter Collingbourne , linux-mm@kvack.org, kasan-dev@googlegroups.com, ryabinin.a.a@gmail.com, linux-arm-kernel@lists.infradead.org, vincenzo.frascino@arm.com, will@kernel.org, eugenis@google.com X-Rspam-User: X-Rspamd-Queue-Id: 399268000C X-Rspamd-Server: rspam01 X-Stat-Signature: rwp6rokqdbsco86a45nuoxawa5ihpg79 X-HE-Tag: 1676530059-389823 X-HE-Meta: U2FsdGVkX18UGEaFMzE3JtAIt/uVyYpBHUb9wiXU6aNiEbAiwCt+bcz+GhanHH10sMhvznI7MGppaysBPvdHpenF/PwKJdt9yp3rwZwvydOBoKdBjTRHw4ixsbrJFzEXhb7SVhwmbkFddNcWblwK3cuKThye6C3dZWzlSLdjaHYmSUgxaVlCirpTB1Jspw8IdZsf2isAl4V2bei6z8bUAOyuQuPI2HSild+eVj9gvZZ1VMw79bYeAv70TrjMF08K8skb4MVgK82MTFzEvoUAwIE05mKj3TnB6xdEMJSJ40/COYX7IbHvDK4z/0rdlKJF/ryVgXZ9Cf+7TKX62YTQI9+vwjcETuxD8dnjrcr70y28PZnm9RHBsvju1D42pqmL9Vbp+G9m0Do40KAS0ZBtHhyzSNcgt590qelMCtLbEPajJo7QGmYlCkbLrwD76EgAim1Ys1vcQPl9srUsSRb3IkZc75ue6+Ev9IfJ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dKovCZMn7m7fk6yGqucHRTgHtt+ZP+rNY6aBKirhjaO1Iaet9O+F9yPmes++Cw82qpjLKOnq+d78n6WGam7sG7Ymm96l1e0pnP+/olmiV6RTchRCMd2oZ/Bz4o6FZgcg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000195, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Instead of changing the page's tag solely in order to obtain a pointer with a match-all tag and then changing it back again, just convert the pointer that we get from kmap_atomic() into one with a match-all tag before passing it to clear_page(). On a certain microarchitecture, this has been observed to cause a measurable improvement in microbenchmark performance, presumably as a result of being able to avoid the atomic operations on the page tag. Signed-off-by: Peter Collingbourne Link: https://linux-review.googlesource.com/id/I0249822cc29097ca7a04ad48e8eb14871f80e711 --- include/linux/highmem.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/include/linux/highmem.h b/include/linux/highmem.h index 44242268f53b..bbfa546dd602 100644 --- a/include/linux/highmem.h +++ b/include/linux/highmem.h @@ -245,12 +245,10 @@ static inline void clear_highpage(struct page *page) static inline void clear_highpage_kasan_tagged(struct page *page) { - u8 tag; + void *kaddr = kmap_atomic(page); - tag = page_kasan_tag(page); - page_kasan_tag_reset(page); - clear_highpage(page); - page_kasan_tag_set(page, tag); + clear_page(kasan_reset_tag(kaddr)); + kunmap_atomic(kaddr); } #ifndef __HAVE_ARCH_TAG_CLEAR_HIGHPAGE