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: 13143696 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40C62C61DA4 for ; Thu, 16 Feb 2023 20:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Mime-Version: Message-Id:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=Qn9vJVBr5jBYGjbg7QOQBC92TauIRQipk/+ptirX1JI=; b=Kyn szvXgn4CWc8H6a4/iYux0r06Onp98EIGTVZiHGlkDnyrqd5VyV3GR9w9AtKNtJzDC07kaSS0RlxxF ukG/SYfzOm/pLAjJP8ktKtPvyp92biT26D0W3d0V36ykuuJ5lbxF2eUWi8ske3/O0Lcj/9fdswaSp DoPC4WbP/AaUIiivtroDo4eQ1EktoEJGEM5+mRVOQmmsgXNNas4vyrJSSZYbzJbWGzzDwMyAGfC5C Q4r1oRzDfP0zB9D9MImV/q2HtIhl5cvnZJzQIptp630E4/K91APTDUvaNh1UL18fL9otKUnL3UPlP smPpt3XRrUtam9xGmdtQuOndqfOKIbA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSkPl-00Bhyg-Ct; Thu, 16 Feb 2023 19:59:33 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pSkPi-00BhxM-OS for linux-arm-kernel@lists.infradead.org; Thu, 16 Feb 2023 19:59:32 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-52ed582a847so32301257b3.1 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=Xa4bf9VysSCqYXs49fdgkDOZ18T03onHdjbDgd3VCd/gjdgb4fUaSaOb+wZ1wiJ/HX pWfb4bdp/Wqi1KKW0lBkuYiwLJr4nD3ij2bQHhnVSImigLP6EUSMTAOSwFUX5Vw6XyC8 jV0FJ6XRIwhKrPEM1wGGJXdoLEqMWBwKBbYsnc0JpTelzgA2foqm/zRoXR2fk5MXujbk CmSGmRj4eueIm/I4wuH7gySldtTb6As15OnF48ee3ebwnxVVNtGzmsFKS7//0ue2IB51 mrmuyWUVWl7BKaF4EVhrZpTLb146fiVCsjSbvK/KNar9od4Z9U3UCOrznfhheOxHjqU1 kWfQ== X-Gm-Message-State: AO0yUKXZkZ73LhDUAWPlOdj5pPuWJGGXU4jhpZWMdATlGjD5OKlCs+3f FZxV7Ee9Rsf8PmkaHThvNlO7BZk= 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230216_115930_815192_B81C7F6C X-CRM114-Status: GOOD ( 11.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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