From patchwork Thu Jul 27 01:16:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13328653 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 D4C0EC001DE for ; Thu, 27 Jul 2023 01:16:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0D6C56B0074; Wed, 26 Jul 2023 21:16:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 030676B0075; Wed, 26 Jul 2023 21:16:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BCB1C8D0003; Wed, 26 Jul 2023 21:16:26 -0400 (EDT) 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 A59636B0074 for ; Wed, 26 Jul 2023 21:16:26 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 78C7114085B for ; Thu, 27 Jul 2023 01:16:26 +0000 (UTC) X-FDA: 81055626372.28.49A6527 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf15.hostedemail.com (Postfix) with ESMTP id EF3B3A0012 for ; Thu, 27 Jul 2023 01:16:22 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690420584; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xYd37JbWctprMIsLniMzviaBXc8Tl5tX0ObDbsc5gGU=; b=A1EJtMyh4nI1657DOTUp24zMExn03FrZwU08ipVuCVumlPAazmfm/FOMXMKIonizuQchVT j8Sb/hPPHSA3ZG8aV4zIMS3t7SzNNoGSxB2BU+tJM/ep7u79R0Jpf9/p7FBv1x93zCycX+ HLCZixiG1G78VSQv4aCbY38GD8pEJ1s= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf15.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690420584; a=rsa-sha256; cv=none; b=qSCth8CYVnXsAgYSFtD9au7Z4+evdcTTpRVhBd7gsfSqLNSZYVm1d8Ttnm0cgI0FUZAu7X UmA9ZvZDuCX6z/H/iRfBTq26Ua3MwIfmXRLM0XScLFBWlttduYxXCw941VZg681X6Xq3oF NIfFAvOcQOPxXdviGYcGQ6Taz2q1ODs= Received: from kwepemm600020.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RBCVF1DzZzTm6Y; Thu, 27 Jul 2023 09:14:45 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600020.china.huawei.com (7.193.23.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 27 Jul 2023 09:16:19 +0800 From: Peng Zhang To: , CC: , , , , , , , ZhangPeng Subject: [PATCH 2/3] mm: kmsan: use helper macro offset_in_page() Date: Thu, 27 Jul 2023 09:16:11 +0800 Message-ID: <20230727011612.2721843-3-zhangpeng362@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230727011612.2721843-1-zhangpeng362@huawei.com> References: <20230727011612.2721843-1-zhangpeng362@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600020.china.huawei.com (7.193.23.147) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: EF3B3A0012 X-Stat-Signature: 9mafub6qj7dgj11ybzcuywtksr8c79bm X-Rspam-User: X-HE-Tag: 1690420582-180379 X-HE-Meta: U2FsdGVkX18l+B+8mnUknSmSPxT/VYFyOrv4ddb6AxnBn8//GWk6dE1gSrj6+nscAZhen+b+K83OdO5GGNjzYE4dtMYgu/lJfB3AI/5tHsgbKIhkoLMqDQ724twQ3rxTO6AbzDwP37/V5g9k8N9eqGJbDk9az8XqlsvZeKOkaQc4tvG+TwnAG7jhGnYdjB+Wm4Yn8B3fRz+d5yP0kmxUxvYy6dS0XFIWusbpwgMoj2eU/Mbkd8w79k982XEhb2MBB6lUtOxRNT+Rj078BDobSEtyx4sOU7/bi8Tw7e+HvtuX44xWIgtN1g0ZGHotlpOiHI6GT0M1vMtUF2D+Ana75TUcwm70wxXUZVTOokRy1UJuNtqnMApvxpiqlEXK/+WCJkgd5kL/jLJ+IFkiR72nfVTUenqj+BnKkxBsiPIZIedWLJDGgCMy909u2tvGr63lFNN0zAmCBQnX/p1oR6IgkrtlFkQlMeIEsBQdcUU8xAi9fr9smOA1u/53nHjrQPsFn8rleYRpTrCbRHuqb0alP3AOARAeV6PXa+Of41183rEZJkV8aOsSGwt1cBRTtpjHa2bl1WO+1Dw8PptrI0WQSS0eV1Obj5b5MhHLZWCzghvh6genKalviV/neOn0HfSOc2wjDqzzknnKwwE9pRFZh7qxCUaOLKXlR6IRKKLGKW/lmkJlyxlo9+PI6C2BaBeM1awtTIZ5Pcq+tYGt3M57zqXoyV/qU81/HDVbOCZ7TkQ52JzHPHZTBP9g5Avo4WGh/4QbICBn701kPSajlKo5K0Ju6JR12OtNl6/QEuB/Dc+D++MEY4n5okvQNYBVkIlDBYU2zrOj3XNJ731n8bb/xAD5NLjgQzfgEg7XAoQeyYMBJgBjq5S6WoyXSTLquCkFrDIvcK8qBKdhNQPwjlfTv+SKtLd+VexHF5qU3yzMPsEdYeEMf9+G6r4ZD2sf3OYv1dp2WEBqsXRvDPX6/3A 28VifDoJ AeYSX6VFSawSk810AIlhSxNGStoESzfuJAEpyVktWRaUe5sPqoGOiCI4jSSp/6JKt8mue24lJVeyZihwyFelyg+b/sZ6vcB4ZBvcjnuQJ0MGTLxS/561JmM4G6qkBVSoN4gr7pl10Q3UMyWL5yK10/shxfioFBxyH5NRbJY3aul/vjupvzLUWjwcBenGHA4qWAYOl 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: From: ZhangPeng Use helper macro offset_in_page() to improve code readability. No functional modification involved. Signed-off-by: ZhangPeng Reviewed-by: Alexander Potapenko --- mm/kmsan/hooks.c | 2 +- mm/kmsan/shadow.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/kmsan/hooks.c b/mm/kmsan/hooks.c index 4e3c3e60ba97..5d6e2dee5692 100644 --- a/mm/kmsan/hooks.c +++ b/mm/kmsan/hooks.c @@ -339,7 +339,7 @@ void kmsan_handle_dma(struct page *page, size_t offset, size_t size, * internal KMSAN checks. */ while (size > 0) { - page_offset = addr % PAGE_SIZE; + page_offset = offset_in_page(addr); to_go = min(PAGE_SIZE - page_offset, (u64)size); kmsan_handle_dma_page((void *)addr, to_go, dir); addr += to_go; diff --git a/mm/kmsan/shadow.c b/mm/kmsan/shadow.c index c7de991f6d7f..966994268a01 100644 --- a/mm/kmsan/shadow.c +++ b/mm/kmsan/shadow.c @@ -145,7 +145,7 @@ void *kmsan_get_metadata(void *address, bool is_origin) return NULL; if (!page_has_metadata(page)) return NULL; - off = addr % PAGE_SIZE; + off = offset_in_page(addr); return (is_origin ? origin_ptr_for(page) : shadow_ptr_for(page)) + off; }