From patchwork Sun Aug 18 15:26:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Uros Bizjak X-Patchwork-Id: 13767462 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 8296AC5321D for ; Sun, 18 Aug 2024 15:27:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 91AEE8D00E1; Sun, 18 Aug 2024 11:27:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8CAB38D00CF; Sun, 18 Aug 2024 11:27:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 792018D00E1; Sun, 18 Aug 2024 11:27:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 555168D00CF for ; Sun, 18 Aug 2024 11:27:03 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B4723A82C8 for ; Sun, 18 Aug 2024 15:27:02 +0000 (UTC) X-FDA: 82465744284.05.10ED2E7 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by imf09.hostedemail.com (Postfix) with ESMTP id F2DD314001C for ; Sun, 18 Aug 2024 15:27:00 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JdlSAij1; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.167.47 as permitted sender) smtp.mailfrom=ubizjak@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1723994764; a=rsa-sha256; cv=none; b=a1boQeIXkXFXblgooidJoMZujbjz8iQTbRODvl6xH7HT/tpf6f0HvdZiek0BHD8MSM5WMj FKR9iuGJ3Lkd+2d7MFg/6NSm7DkP3E2t80q35+Qk+KtAhuaH3PqvXYFBLZ9JDysXHMPrPm B9psprONN1CpYwCBxu97FG7tk5VFifU= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=JdlSAij1; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of ubizjak@gmail.com designates 209.85.167.47 as permitted sender) smtp.mailfrom=ubizjak@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1723994764; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=RHx6D1zKrkAV68zeEgpHIyICDAfmO0Yll8Q2BD72P7o=; b=RiOo2D11nAC+puOzIEp88/7NyPftmU2bW6FVuue1XmDTOWJzWzPyQmqXra34Pa7W0i72jr 68oUEoSH6iLzsLbwO0mw/BD2n8RnFPSeHaSa469/NTucUq2DQt4bRhiKt0kvbnePLtJ/b1 xkCAvvnTPY9+KN42C7Jqt3AacXv2UkE= Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-5320d8155b4so4678328e87.3 for ; Sun, 18 Aug 2024 08:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723994819; x=1724599619; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=RHx6D1zKrkAV68zeEgpHIyICDAfmO0Yll8Q2BD72P7o=; b=JdlSAij1yfIyr5r3KUkQ1sgtD80sB1hnTXwMYQFl5Wz/4zTgM+aEdZRcOhF0FWsx1e Kab7KQE3wO8S1jyAoNNhrRMvhfQkuxUg62S/qUnIInzCI6Z2gtYeDk95VFkkpVfAOfzM Oa9MtYrLHwGAyEb3y4lK+UUojpyIYclt0YtHBxEHBt7aC0kmQIAQPy56LrpNrHCtmvGn KVf+1kurJWL9l+rBLuP/hbyFmaT/tVrfZU1l3vB3qd6/ZZu3y/kOZrO7Tr9fJbtwpuMv CZuhnvNgE//WCgdO1hiPItkfnta4M0bcvsdy0aSpl9BTfN8WeVwSaeX0FPRw7HOsVlEc ddng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723994819; x=1724599619; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=RHx6D1zKrkAV68zeEgpHIyICDAfmO0Yll8Q2BD72P7o=; b=lKJ/FVRF8nBMeF7iF9M8qlhkzYVdBhd4VZyFvxaFlCBAhCCf0wF/jBiqDolnynFiIJ OpgkTdP+Jntwq6N8oslhUHpolrgjEMCrVaBWg0YVk/vDPfzOwrrj27hsmUc8x0n8KV+8 aD+G73+pg6dDP88dBCWRU0231S/JjPckm9lkxNyeZeajrqBqm1O1mctsBFokZU31NfuY IYCvZ/8utrvYRYZyFuudaapKYW1QmZDSFgl3u4zeUkfjWv3vWsURJvY5anMGQ4vk3I8F O+P7CHnQwVDYYvGVbARDbiLK6AKbExIAJaEN2oDNXHx16UPNFdSc0xcA2Ska7W9Ga928 CPpg== X-Gm-Message-State: AOJu0YzaLDXKN1PARTKlSZ6/WaK7RtJuXsUwY5Jdkxp9bQoBcdoR77PD 69GRq9DTtRhTNZtTDbKBQwO6ITPKJqj/QPXudQk9SiTQDBdqfwChj+zfoQ== X-Google-Smtp-Source: AGHT+IEkeS6ykZk1MjvKLwnRlKxacIaVt3qa2Z7l0SNRPjt79dqhcsjQGzRgvxSG+RaYtiqcOXbOcA== X-Received: by 2002:a05:6512:3b21:b0:52c:df8c:72cc with SMTP id 2adb3069b0e04-5331c6d98d3mr5226359e87.43.1723994818326; Sun, 18 Aug 2024 08:26:58 -0700 (PDT) Received: from localhost.localdomain ([46.248.82.114]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a838396d0cdsm528574766b.219.2024.08.18.08.26.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Aug 2024 08:26:57 -0700 (PDT) From: Uros Bizjak To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Uros Bizjak , Catalin Marinas , Andrew Morton Subject: [PATCH v2] mm/kmemleak: Use explicit cast to cast pointer from percpu to generic AS Date: Sun, 18 Aug 2024 17:26:11 +0200 Message-ID: <20240818152634.17443-1-ubizjak@gmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Rspamd-Queue-Id: F2DD314001C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 9cpf1rr3sfoyeipjqzaxapfbgjid6x35 X-HE-Tag: 1723994820-940872 X-HE-Meta: U2FsdGVkX195IF0Pn6cQWf0GFUReTNbBH/9V1MfJ9tV/7ONPErQYNRSMB6OQZp++o/xwvJLqXYHqxO1W3pCuKtR5/zkaWyIe97HxnTylkES5EWS9yp4Db26lVOTPBmWPKlpKzsGe/voWp98fWkAkLNenF1J55FpHEdgNGTbURRJioIgKeg8re2t3atctJT46Ag2T6VN05uwiJTVBszBOJ5Oy1ZO7RKEVYhtBmIiisiP8acuA/YvhgWZ1ARJBLp3hCIfF+YraNWt1tDh4W/IMUu2kGl1NUhod8nWsP8REt9Bk8OPBBAiVdvMRIHwHDAEnGuyqTHbY/WeTR5nYyvZB2F/Tb8J68s7E1szFdPsSuk94Kn9vtyT55M3APitbk6gy3nqpyr+PM8AHA02eeboIg3GgGbFSilYWLIMgLA7eOrqg3V6M7rKm347dkh6O7ZHDik2bKgd7S2FgN4AwsVE9ZB73k6VkLZdUfiQuD6sqUVeS7u65HsRyWREDtAg1B6BODLCif4rh+YvIE+fezj3hYfQmfWkUj5PyxWQJhhfz04fwyYUYVKABOiTkAWG1/qk9hESjRLGl/wzizY2d4QuMFMy6qk6WMZhmlc0AYRdzOi2jkJ26FbcSWroAKZeDMjwKGAR6jb3TMHFdoGJKGFTtteOsQTJzkQEiLVPtai8OhH1MlUezPWfmZJ6O7a54/QJs1iS90BECTo7SARJYB2mSlaq5zdkdFg6Yy8Hvt/juZPnL9YrYAFPcfPW+nQsEoJnD5/9hUx4ATz5YTzAa/WU1a2lddA5XGzlMI+KPT04WVuGVQUEAyiT0Cqkv3VBVUzX4sYokxHFXXqgQlZqnQ7/r86vWgblG2zwJneq/9sRp9EfiDLBrRqMuxeGAv0BWhEZzqs3BxkJFNjGSSFSzhSWx1NGDlTU9ow7hoeluPkrePw7QTDrzrMencUwd7iG0gerHEGEmuM/AOKlSScYOqe1 wSze8qAE GWWIbO4JoITJA8gT7fmQFsme9dR8UjUgT2ElQe/z1vZZUryWyHi1SN+YTphqvwrje8ug3K6A0zCwC5GzulCmivcLWDSmuE30gIPXIlTWd3oAiNK0LQnQs1qEyybh+U44U1JWTEqeZMHEftOW13vfi64tEKnPEg1hU171H9Wr5oc0roM3Sm/w1vSXbHcP+QaAg7DK4gcjFyUcGofwGhwoQq0Yf3z/StOAHczWDgmoX9OgtORm+RenUUY2xuRNBgfSFuGrVJQuW7dFbtE4t1QCBuR3MnU8uXPnCWDA+H6zXzmG1YZJsJJI/nAkE9H3b2SAhSR3rremgqI7yUQH0/xbDstVOc2IIDU/ehKrZXauS3yLoQVOksqocmEHZtSMUZmTYVdbn4KjhhYPhUvDVyEZb5wp9z328+U7Ge7SpOgc2vfCLe3bOiWlVDcH9q5PUPacOlULXYzluvWcP5BNiJygyg+bAJA== 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: Use explicit cast to cast pointer from percpu to generic address space. The patch will avoid future build errors due to pointer address space mismatch with enabled strict percpu address space checks. The patch also fixes following sparse warnings: kmemleak.c:1063:39: warning: cast removes address space '__percpu' of expression kmemleak.c:1138:37: warning: cast removes address space '__percpu' of expression Signed-off-by: Uros Bizjak Cc: Catalin Marinas Cc: Andrew Morton --- v2: Use explicit casts instead of IS_ERR_PCPU(). --- mm/kmemleak.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 764b08100570..fc2e09ec48f8 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1059,8 +1059,9 @@ void __ref kmemleak_alloc_percpu(const void __percpu *ptr, size_t size, * Percpu allocations are only scanned and not reported as leaks * (min_count is set to 0). */ - if (kmemleak_enabled && ptr && !IS_ERR(ptr)) - create_object_percpu((unsigned long)ptr, size, 0, gfp); + if (kmemleak_enabled && ptr && + !IS_ERR((const void *)(__force const unsigned long)ptr)) + create_object_percpu((__force unsigned long)ptr, size, 0, gfp); } EXPORT_SYMBOL_GPL(kmemleak_alloc_percpu); @@ -1134,8 +1135,9 @@ void __ref kmemleak_free_percpu(const void __percpu *ptr) { pr_debug("%s(0x%px)\n", __func__, ptr); - if (kmemleak_free_enabled && ptr && !IS_ERR(ptr)) - delete_object_full((unsigned long)ptr, OBJECT_PERCPU); + if (kmemleak_free_enabled && ptr && + !IS_ERR((const void *)(__force const unsigned long)ptr)) + delete_object_full((__force unsigned long)ptr, OBJECT_PERCPU); } EXPORT_SYMBOL_GPL(kmemleak_free_percpu);