From patchwork Thu Feb 16 19:59:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Collingbourne X-Patchwork-Id: 13143693 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 BD637C636CC for ; Thu, 16 Feb 2023 19:59:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E17966B0071; Thu, 16 Feb 2023 14:59:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DC9416B0072; Thu, 16 Feb 2023 14:59:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C8F596B0073; Thu, 16 Feb 2023 14:59:29 -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 BC9256B0071 for ; Thu, 16 Feb 2023 14:59:29 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7E8AA1202F9 for ; Thu, 16 Feb 2023 19:59:29 +0000 (UTC) X-FDA: 80474219658.04.71ED6F4 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf09.hostedemail.com (Postfix) with ESMTP id C1206140005 for ; Thu, 16 Feb 2023 19:59:27 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=MfYxEJgQ; spf=pass (imf09.hostedemail.com: domain of 3HovuYwMKCBUAxx19916z.x97638FI-775Gvx5.9C1@flex--pcc.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3HovuYwMKCBUAxx19916z.x97638FI-775Gvx5.9C1@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=1676577567; 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=3QfkogShxWtsNsvou0R7Oeyf0p1vHT8U6yd4wg7Fm6c=; b=rzJcRYlHViIZX8OdW9DCHyuzYLL6Re2oynin5A+zB550w6zL099ntHcwH0pM4wnVHrbIqG ueyz3WV7pXMR9vHKsOMIRsjUT/LuB/NUNxsbxdiCf6nPbWs0ww2vXUkPX6CUTFalKrDapZ 0A2Kl/fvVuNOmAdd89XrlpJRNC+Amyk= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=MfYxEJgQ; spf=pass (imf09.hostedemail.com: domain of 3HovuYwMKCBUAxx19916z.x97638FI-775Gvx5.9C1@flex--pcc.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3HovuYwMKCBUAxx19916z.x97638FI-775Gvx5.9C1@flex--pcc.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676577567; a=rsa-sha256; cv=none; b=GJdM2ISIkb9+V+rq9AYxMaIZYVAUrTZFU5X+LESJYd74oge67KYv4Iu6+UiEPD2gToZE6O OqtCjv2PN3dIbkElomOUb9nONBG7SiGt7w86zFQ2QPanqW0Fz1Kg6T2jf4sa+nfHwkEhbI EU0Uue/+8tLe3Texk4j/ILVoUvzzjjc= Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-5339cd92124so16735477b3.7 for ; Thu, 16 Feb 2023 11:59:27 -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=3QfkogShxWtsNsvou0R7Oeyf0p1vHT8U6yd4wg7Fm6c=; b=MfYxEJgQ+QU3m+KvSuRXzoeyxJvS0Wk3qWhFwNjDQRg8GWGPTc0eLRnpWlKrnaD727 LWdgnYR+wYfVFf6Hi1dvfJm+sbWEMfH2lbsboey+5OHPMcLt0/pjIEHMNsnb1hJrbSra ZPdwBziANfoKFkTCNws4n11QB8aYshJQexThbP+u7QXm31vg+EW25ljkgQPwGYMFKnMX q5/z/6m8vnLPlwVpd9uK75UlYYqjS+bn+ZPe/SM3PGicTGf/Sazp0evsroYNCKA/tESb TYOuHka5HWGKN8Vxsxa1wagYVGq3IVgJogZaNad5NY4Raz1matncMIY5+kf/YPxkGHqB 3I5Q== 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=3QfkogShxWtsNsvou0R7Oeyf0p1vHT8U6yd4wg7Fm6c=; b=r+qJ4MnS3uVeXESO9/6H7qgt3AtxLSU7s8NWvQhJ3blsD9rpqqaGL05ot5TDG+bEVG KA6uHvlVJY96o57UfMyXTrpfLCAnwNtjd72LMK94YLyThjoMYrl8JX0MnWpgvNJ2V8JA 9F7J82KW90PKW/YQ2nFc3hePmUGSZkaaEiDFW4M1KfNXw+lj4UGRPcPwxIJ9JoTi9Vdb PvMs13Q5eZccYwwOV9GoBcUU9r8zCOM3RpmzDNwgW+ZmAP9lXJ4vXz1i3UP+vOGDjZaG oLX5Mv4S05j2WqVt4ZUlXZWmTgbFTnEeLvJFwesbqOh39JUKp1Gq3FfVfiHw3/pTfkoZ 1JJw== X-Gm-Message-State: AO0yUKU7maaFI9vnEVqbNcRWyvdMU+HKvsWH8nK3ECJE6rARpiLAivgS R6e4bCBqvpXv1pj0VlX+wd4wHaM= X-Google-Smtp-Source: AK7set+Q7MxxyFWIFC7Wb4GUwOCqZ39czsXk87qtl89dJg/OwDFwaEAXVaJWTvmr+Z0tZ6QlGkRdUDk= X-Received: from pcc-desktop.svl.corp.google.com ([2620:15c:2d3:205:9dcb:3224:f941:1aad]) (user=pcc job=sendgmr) by 2002:a81:9e03:0:b0:52e:e396:3ad with SMTP id m3-20020a819e03000000b0052ee39603admr1016051ywj.171.1676577566917; Thu, 16 Feb 2023 11:59:26 -0800 (PST) Date: Thu, 16 Feb 2023 11:59:24 -0800 Message-Id: <20230216195924.3287772-1-pcc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.39.2.637.g21b0678d19-goog Subject: [PATCH v2] 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-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C1206140005 X-Stat-Signature: qma9kuyjnoisegbcukmnhdu5o39qaq19 X-Rspam-User: X-HE-Tag: 1676577567-541080 X-HE-Meta: U2FsdGVkX1+uOYmMzQsoYPnPBU9J1VeWQJ5tfP67nXfreyI5TSg3B8RL7GhJdDoZYkF50xu47ZYHsxygmPlkXcuPwwvnQKUo34f0HFGwoHndZWGy44ZNeHxeoZcpJ8/vtD3TiNrDd3QRPjT58VQMoqkJ2Rn9ekLwK+1JZm4Zk401Tb1SVsa8le7sc5Ilj5SrFWmZNHAJmV/GaUSoOf9U2HGbG29U7BZpYhtS5Y9Kj/EnVeA+Neq1iUVKud5oiCq77Kwg+4dCi9WEUE9z6o4e71q+8o1wY62TNuMYBe7q7TBIHCW39j8eFVSHRx6VTob3pZ3roxZcrK7JNAXPXK1UKQLJNmboQu8/3wOeWN4ICjlDIK7dQ4k9Ipqnxhhq3gBGy1IjXIhJz2BmgubPsEhjOKa9W1o2Gy9UVxPy45+jgC572SmF7gA23Jds9HMgEkNVRWPXZUXU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3Bpin5ec1XCyuZ40r1S5iU38sqM1oGkgqKF39GcxZbeim0OMIwTyxLqK3oK4xzUZ6C+uVBnRgf7G/5B5shooMRlGZCl/3bebE+5+/k8t3e2sC70z4B4LoR6u9iMqO1/HJbXZYDpE7uwSszOLQn4+F9PRmMZz1YQf7ucGlN3F6n8/xbrDW3AOoV4knnTcjHlbQc6fyTEgCXJ/vfo5HyOQa9pZTiyxYE7ut7rBtIglKS3FG42Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.023564, 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 Reviewed-by: Andrey Konovalov Reviewed-by: Catalin Marinas --- v2: - switched to kmap_local_page() 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..212fd081b227 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_local_page(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_local(kaddr); } #ifndef __HAVE_ARCH_TAG_CLEAR_HIGHPAGE