From patchwork Wed Jul 31 02:54:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Tikhomirov X-Patchwork-Id: 13748012 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 200C2C3DA49 for ; Wed, 31 Jul 2024 02:57:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 917A46B0089; Tue, 30 Jul 2024 22:57:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C7106B008A; Tue, 30 Jul 2024 22:57:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 768586B008C; Tue, 30 Jul 2024 22:57:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 530A46B0089 for ; Tue, 30 Jul 2024 22:57:20 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 941A7A01B5 for ; Wed, 31 Jul 2024 02:57:19 +0000 (UTC) X-FDA: 82398536598.23.4D3AB49 Received: from EUR03-VI1-obe.outbound.protection.outlook.com (mail-vi1eur03on2099.outbound.protection.outlook.com [40.107.103.99]) by imf17.hostedemail.com (Postfix) with ESMTP id 9F15740021 for ; Wed, 31 Jul 2024 02:57:16 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=virtuozzo.com header.s=selector2 header.b=jDWtmkpC; spf=pass (imf17.hostedemail.com: domain of ptikhomirov@virtuozzo.com designates 40.107.103.99 as permitted sender) smtp.mailfrom=ptikhomirov@virtuozzo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=quarantine) header.from=virtuozzo.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722394632; 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:dkim-signature; bh=ZKeqphtEOBju11zfTP+TwSqnt0fLzZERCrRNXEXf0YY=; b=H/h1DtusC4d6iHJ4aAfXN05uOVuu4NBjQvP9sQijHvBZ0K8F59ZR9qF9KVetlvDsSQOlp8 1cvk9jvJ5Bia3gAyvibLosmp36pu1Eh/fWfq6lIy7JmnRPnmK/1MwSaES/iu5eeocr8G9O DQCzgCdzerQ8+Vu/Eod/cvgwuOfrLBw= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=virtuozzo.com header.s=selector2 header.b=jDWtmkpC; spf=pass (imf17.hostedemail.com: domain of ptikhomirov@virtuozzo.com designates 40.107.103.99 as permitted sender) smtp.mailfrom=ptikhomirov@virtuozzo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1"); dmarc=pass (policy=quarantine) header.from=virtuozzo.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1722394632; a=rsa-sha256; cv=pass; b=OgSriVN2+fKid+s7Kx4qAvD1pmpGNfTYPcFTx8XdEXDDiufnqcHmTAKPfniZamTJgnP+j8 ej4ojptmlac7Bg0jgDtbAPwN+nwxCzomTXobbvri0T3JLDmuu6+K5Ha2nfhB13sAEO/Ilt wHxH9AlynUxt0lbl5O6UlciLZqr0NO8= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FGLQOsCUiz6k0MAw5yNAQ/VVJYfaBFH1jbZrAJvvioLc/+av6i3ANQslPscemKOcO3xUbJ6tEaEB+ArR1PDGSdvSul6nwa8w9QjhTVP+B0TAiBVpT7xoVbub5KROyjMpXFZwwg+kTdi9mlBMfF6RxsDyRKuid8s3+lfAv0Il7xxXo6elaKM9+XyDqJTF4aylRqsOQWeKP3T9U1qxCEKMnL6VWx8YU2yLrRFG2S7la/vwlEjbgRNFGylcb52GAjWH+xJTKUu80g2SHWZ6sPK+RDThai3NM8TFYKfh4D1MYVZvElcqYxygXjknRiiQgGwDvz30wIQxfTecs3AJrsZROg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZKeqphtEOBju11zfTP+TwSqnt0fLzZERCrRNXEXf0YY=; b=h67uS2lnqHUkjliWPOc/A+F5qy+RBAIiKrLWZkAJ2zll43FriVd+W7LhdzLB/pW8zMtxQOhCcVOXgT/8DtZRTLELium66SQtl+H327XulvseSdOV6oroK6nek03QS166VxG9UkmbB635a0THFGCAux2BCdRgGDC7brg++s1XUK4BO31TD5QnZACAC3RkOwj+edoQW9txVnoZsMwhAusCpRQdZvUOIz8NvLUsRn+0v0UP960c5HzUPD8TkgJ0x7W7KfsODDt8bOrRLmVRUvyyoa3WGZUZNSLPjWrGxmHSQ+qaFPvBdEVCF7sEzi2/misttqBLCBqTgUOebozVP1ja4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZKeqphtEOBju11zfTP+TwSqnt0fLzZERCrRNXEXf0YY=; b=jDWtmkpCTQ9NnySdmhOL6e1iL23jZZ0Xemw+mnuxws393RFQdduc9gUyYQ5EMPozBoba07zxHLj+HAM/hKiL3Gw0gAIu+Tuf39/c6DALoXyVwKh20ygyFrA2PO3654uby0/82omfEl7wTyN0uz862NiszkqRbdZ/LcAeUd7CG/BfnH64pC/POZWPUCo8AcCL/JvgjqjjyHgJaLXYbfA2JXhOugjFNw6fAbzuiLr7keUOOKa4R2inmP/0ayt2tE4ncmpqELJb/8XMcj/f75lkv7A/eGJcSg5Z4nMpp4J4k8KSKtgVKpKHLJqAOCseua+fTGEJ5gVX01W00ljPXKjgWQ== Received: from DU0PR08MB9003.eurprd08.prod.outlook.com (2603:10a6:10:471::13) by AM8PR08MB6483.eurprd08.prod.outlook.com (2603:10a6:20b:315::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.21; Wed, 31 Jul 2024 02:55:45 +0000 Received: from DU0PR08MB9003.eurprd08.prod.outlook.com ([fe80::7261:fca8:8c2e:29ce]) by DU0PR08MB9003.eurprd08.prod.outlook.com ([fe80::7261:fca8:8c2e:29ce%4]) with mapi id 15.20.7828.016; Wed, 31 Jul 2024 02:55:45 +0000 From: Pavel Tikhomirov To: Catalin Marinas , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yongjun , Chen Jun , Aleksandr Mikhalitsyn , Pavel Tikhomirov , kernel@openvz.org Subject: [PATCH v2 1/2] kmemleak: enable tracking for percpu pointers Date: Wed, 31 Jul 2024 10:54:09 +0800 Message-ID: <20240731025526.157529-2-ptikhomirov@virtuozzo.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731025526.157529-1-ptikhomirov@virtuozzo.com> References: <20240731025526.157529-1-ptikhomirov@virtuozzo.com> X-ClientProxiedBy: SI2PR02CA0033.apcprd02.prod.outlook.com (2603:1096:4:195::20) To DU0PR08MB9003.eurprd08.prod.outlook.com (2603:10a6:10:471::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR08MB9003:EE_|AM8PR08MB6483:EE_ X-MS-Office365-Filtering-Correlation-Id: 720c689f-365f-4b35-6e8a-08dcb10c4629 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014; X-Microsoft-Antispam-Message-Info: 1DvqCoG5JwbSXEFN7ffASGQD9x2xjVwVNsqFTWkEwal6rUBEHxZ/UUXLiTigPOZFQzmCK6ohTBFmQPkCy5WFQ+QrGXRy121YqnozZGzFolhutX9ViqVzarFFapESHSdmbftamhHuikMwK8VMXSZtk5zMrljjaG5o6lgDNZnRNDIqeyjeh3q8oqa0DOy4G0CZT+Xgw6P6dXy5Aon0GZReQWnJ8dTZYywcQeqbCPjKki19KJ6B1GNO+kQlKvPUrIV468AqZ9Vxb4Niq4JSCImIvAkpnpIGiqRyFvWZPeJR1l2DlsRASJOtYpOI2dTJXEx3uuWCnMpBKtYr14eQ1FVh/PuQ0RGclEIV5omyEWc5TyhKX8T48wGheBN0vql2xyUvs/4t7gw3kzVA1iSUiPZEutryJ0PB/Dbe3BGNeJml5+povBvmK8lreAHJhTyibaChPQxsOGQ5jastWzcX3AlqTtHoY6vZ0ut3+a+0BgKTsp+GXqzsxO01WG9wsS+AVaANOKuJLOvt4uYTzQxQ6wSFTwwdnMYsSsmKIbE2t/6y418wkZZ1th2jj1fo/Fcc4oRcExynNrmb4HkQA1pZD66jj/eExys1rupR2y2S8gbFX2xi231X1lPaKi/syiVgnZWEAIS3E5/ylINa6N+nCtMhd0uZYvbdtkUDKyYHTLOoAr/ckuKCueMQhKPpKB49L79ztRe0QkV2hcqo5FgQ7gVz2Vk5k2TEk7VSGlijNQLtbbQI60JIZwYNHZznYUG0Klp5uh5y0LcWGkJ4ipynX/xOsCtxdVtDpDaLo/NS6fpnXaWOBBlYxU0DKk01k78beeXYwDvch5Sy63ZeOvqpTAmv5psJn1DNOjS8CmjagP7EXfnRgCip5YJaseaGryXZ59fok1K18jh5KkLIlDHzf3xlFJKHRRzM5WNLocMmC4x08catPEL13uyPlpZ5Z/0z1eqfm0TCI2uAlA8jA7ARqIz4EYsnekOIEQzST8kYw5FGhZQwkxk+8fXdsSGKO/SCd6VBSm5WwomoEa2ZXUM7P4LClEbSQChDZvIUvijueOdGBDr9+ZwBS/BIYMG8Me7imZOtj13RV06pOuJtYkc/za6Dr+RZtKGIf3LMeFEmQoiNTng716Pd/Cv5T0wPH7A3qTViMHJj2UOLsPgiTF+OXeJt4KE1qy9TyXZhENXGrMlR/stxzNPVi71DkWngElOxUkG3qg7TtM//IotbCBVY+d+pm2oRIRoy7qiDZQEwv4rNPEVQqtaePTsPyXyIa5XCU3QXf7gzvYf3DWWMWRW8u/yGaFzEWWo0zhn0jXdeAKI1RSEEInqqJeoDVqXR4vF9CjsjnDceTd30fWM0LZn31wCSjg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR08MB9003.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5gZj7LdCCZcA7Z2CBQO73APmijBflRIb7ae25vCUCxAjNmBiMPZVZkPM2O+M9ZEnXPYimSoHeN5NIqc0+0D+/WKQ0iNJOMkrS42Gs2ZzaxU7GuNAec9ihUbYtioHyaUMYy00vcw+N9YvcFhG7k5Lu2Xzx08aTDitI4wmIlcVqeDmTlaAcg+MJtfqrawa47G7NiQuLfRCEOlwPMrwz8YqWECSTc1suowI4p1J6JYT/F2xSINvTIvunPXPaGD2lhwhvCDt3JbUxJRE5Y1t0yfzJ6M7LaEb4x301ZcAGrvm6puWIwYnyZhOIP3tYmp6QKo73PLMogQ9t7HSv4qek6AZ/TJ+bT+wxxi9lhnpowAV+Dv+6HTdNMCjEENeD78gG7JKdXiYqBgK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CT+QXiTWFLeI44P54T8OSHVVpv2n8NEf3P5WXAHeQPMDOeAxrG/twQn9dx0PIi4G9Sv9/bQPdBwZg+v1Ix0/F/r/huJyM8bcjR/6U1uj4gwGZnZ3plMmIsueT7AqhtH29ErNbMyP5eUE2PlIep4jxafK8VhwhBsK0RR2k8iPnyFmxY4MS7h1EtSQ6Ai2qUeI/4fsEmZTHYDp6mm2Q== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 720c689f-365f-4b35-6e8a-08dcb10c4629 X-MS-Exchange-CrossTenant-AuthSource: DU0PR08MB9003.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2024 02:55:45.5376 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RwuAj9dAKqcsW+MIdkw7KnQ+ofNUWQytTpFCUBYvOFT/W2YB+rjd1V43Wv8bcNcJtr76Ido0eIySh6lLm4u8n6xY8zO1XZ7Pdp5clSjo7H4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6483 X-Rspam-User: X-Stat-Signature: i8fst47nm38qiyaismso631fzzzq4u4j X-Rspamd-Queue-Id: 9F15740021 X-Rspamd-Server: rspam11 X-HE-Tag: 1722394636-442059 X-HE-Meta: U2FsdGVkX1+KI59sjwXPI6r1cxFtkUT6x9+0UrByXcyy82M/EaEdRWHz1BrOh1X3WZDqC0SpW8JS/XXVt6KGpkbrTH93oQEMPTrZEuLv+Rx8COZ3LJfnH5uxkLNKwkw/pM4vU+faLi0QRHTj6WxgVgHvZE4VWH30HhA1BgTG0KgU7JpQliz5BOPwiNPBY2m9C2ATIuFC2XKO8vH6Ec2WcQQ0YwbdHT4X5m6dN9vJcrN7eC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eYNVsn3hFR0dv6TTKcBmfRbxe0BScH7IRKPZ+UY52pdq70viBxVJY336+4VLb78SgA3VfdkTnqcsMkYjQ== 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: This basically does: - Add min_percpu_addr and max_percpu_addr to filter out unrelated data similar to min_addr and max_addr; - Set min_count for percpu pointers to 1 to start tracking them; - Calculate checksum of percpu area as xor of crc32 for each cpu; - Split pointer lookup and update refs code into separate helper and use it twice: once as if the pointer is a virtual pointer and once as if it's percpu. CC: Wei Yongjun CC: Chen Jun Signed-off-by: Pavel Tikhomirov Reviewed-by: Catalin Marinas --- note: excess_ref can only be a virtual pointer at least for now v2: rename confusing scan_pointer to pointer_update_refs and move it just after update_refs --- mm/kmemleak.c | 153 +++++++++++++++++++++++++++++++------------------- 1 file changed, 94 insertions(+), 59 deletions(-) diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 764b08100570b..6b498c6d9c34a 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -224,6 +224,10 @@ static int kmemleak_error; static unsigned long min_addr = ULONG_MAX; static unsigned long max_addr; +/* minimum and maximum address that may be valid per-CPU pointers */ +static unsigned long min_percpu_addr = ULONG_MAX; +static unsigned long max_percpu_addr; + static struct task_struct *scan_thread; /* used to avoid reporting of recently allocated objects */ static unsigned long jiffies_min_age; @@ -294,13 +298,20 @@ static void hex_dump_object(struct seq_file *seq, const u8 *ptr = (const u8 *)object->pointer; size_t len; - if (WARN_ON_ONCE(object->flags & (OBJECT_PHYS | OBJECT_PERCPU))) + if (WARN_ON_ONCE(object->flags & OBJECT_PHYS)) return; + if (object->flags & OBJECT_PERCPU) + ptr = (const u8 *)this_cpu_ptr((void __percpu *)object->pointer); + /* limit the number of lines to HEX_MAX_LINES */ len = min_t(size_t, object->size, HEX_MAX_LINES * HEX_ROW_SIZE); - warn_or_seq_printf(seq, " hex dump (first %zu bytes):\n", len); + if (object->flags & OBJECT_PERCPU) + warn_or_seq_printf(seq, " hex dump (first %zu bytes on cpu %d):\n", + len, raw_smp_processor_id()); + else + warn_or_seq_printf(seq, " hex dump (first %zu bytes):\n", len); kasan_disable_current(); warn_or_seq_hex_dump(seq, DUMP_PREFIX_NONE, HEX_ROW_SIZE, HEX_GROUP_SIZE, kasan_reset_tag((void *)ptr), len, HEX_ASCII); @@ -695,10 +706,14 @@ static int __link_object(struct kmemleak_object *object, unsigned long ptr, untagged_ptr = (unsigned long)kasan_reset_tag((void *)ptr); /* - * Only update min_addr and max_addr with object - * storing virtual address. + * Only update min_addr and max_addr with object storing virtual + * address. And update min_percpu_addr max_percpu_addr for per-CPU + * objects. */ - if (!(objflags & (OBJECT_PHYS | OBJECT_PERCPU))) { + if (objflags & OBJECT_PERCPU) { + min_percpu_addr = min(min_percpu_addr, untagged_ptr); + max_percpu_addr = max(max_percpu_addr, untagged_ptr + size); + } else if (!(objflags & OBJECT_PHYS)) { min_addr = min(min_addr, untagged_ptr); max_addr = max(max_addr, untagged_ptr + size); } @@ -1055,12 +1070,8 @@ void __ref kmemleak_alloc_percpu(const void __percpu *ptr, size_t size, { pr_debug("%s(0x%px, %zu)\n", __func__, ptr, 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); + create_object_percpu((unsigned long)ptr, size, 1, gfp); } EXPORT_SYMBOL_GPL(kmemleak_alloc_percpu); @@ -1304,12 +1315,23 @@ static bool update_checksum(struct kmemleak_object *object) { u32 old_csum = object->checksum; - if (WARN_ON_ONCE(object->flags & (OBJECT_PHYS | OBJECT_PERCPU))) + if (WARN_ON_ONCE(object->flags & OBJECT_PHYS)) return false; kasan_disable_current(); kcsan_disable_current(); - object->checksum = crc32(0, kasan_reset_tag((void *)object->pointer), object->size); + if (object->flags & OBJECT_PERCPU) { + unsigned int cpu; + + object->checksum = 0; + for_each_possible_cpu(cpu) { + void *ptr = per_cpu_ptr((void __percpu *)object->pointer, cpu); + + object->checksum ^= crc32(0, kasan_reset_tag((void *)ptr), object->size); + } + } else { + object->checksum = crc32(0, kasan_reset_tag((void *)object->pointer), object->size); + } kasan_enable_current(); kcsan_enable_current(); @@ -1340,6 +1362,64 @@ static void update_refs(struct kmemleak_object *object) } } +static void pointer_update_refs(struct kmemleak_object *scanned, + unsigned long pointer, unsigned int objflags) +{ + struct kmemleak_object *object; + unsigned long untagged_ptr; + unsigned long excess_ref; + + untagged_ptr = (unsigned long)kasan_reset_tag((void *)pointer); + if (objflags & OBJECT_PERCPU) { + if (untagged_ptr < min_percpu_addr || untagged_ptr >= max_percpu_addr) + return; + } else { + if (untagged_ptr < min_addr || untagged_ptr >= max_addr) + return; + } + + /* + * No need for get_object() here since we hold kmemleak_lock. + * object->use_count cannot be dropped to 0 while the object + * is still present in object_tree_root and object_list + * (with updates protected by kmemleak_lock). + */ + object = __lookup_object(pointer, 1, objflags); + if (!object) + return; + if (object == scanned) + /* self referenced, ignore */ + return; + + /* + * Avoid the lockdep recursive warning on object->lock being + * previously acquired in scan_object(). These locks are + * enclosed by scan_mutex. + */ + raw_spin_lock_nested(&object->lock, SINGLE_DEPTH_NESTING); + /* only pass surplus references (object already gray) */ + if (color_gray(object)) { + excess_ref = object->excess_ref; + /* no need for update_refs() if object already gray */ + } else { + excess_ref = 0; + update_refs(object); + } + raw_spin_unlock(&object->lock); + + if (excess_ref) { + object = lookup_object(excess_ref, 0); + if (!object) + return; + if (object == scanned) + /* circular reference, ignore */ + return; + raw_spin_lock_nested(&object->lock, SINGLE_DEPTH_NESTING); + update_refs(object); + raw_spin_unlock(&object->lock); + } +} + /* * Memory scanning is a long process and it needs to be interruptible. This * function checks whether such interrupt condition occurred. @@ -1372,13 +1452,10 @@ static void scan_block(void *_start, void *_end, unsigned long *start = PTR_ALIGN(_start, BYTES_PER_POINTER); unsigned long *end = _end - (BYTES_PER_POINTER - 1); unsigned long flags; - unsigned long untagged_ptr; raw_spin_lock_irqsave(&kmemleak_lock, flags); for (ptr = start; ptr < end; ptr++) { - struct kmemleak_object *object; unsigned long pointer; - unsigned long excess_ref; if (scan_should_stop()) break; @@ -1387,50 +1464,8 @@ static void scan_block(void *_start, void *_end, pointer = *(unsigned long *)kasan_reset_tag((void *)ptr); kasan_enable_current(); - untagged_ptr = (unsigned long)kasan_reset_tag((void *)pointer); - if (untagged_ptr < min_addr || untagged_ptr >= max_addr) - continue; - - /* - * No need for get_object() here since we hold kmemleak_lock. - * object->use_count cannot be dropped to 0 while the object - * is still present in object_tree_root and object_list - * (with updates protected by kmemleak_lock). - */ - object = lookup_object(pointer, 1); - if (!object) - continue; - if (object == scanned) - /* self referenced, ignore */ - continue; - - /* - * Avoid the lockdep recursive warning on object->lock being - * previously acquired in scan_object(). These locks are - * enclosed by scan_mutex. - */ - raw_spin_lock_nested(&object->lock, SINGLE_DEPTH_NESTING); - /* only pass surplus references (object already gray) */ - if (color_gray(object)) { - excess_ref = object->excess_ref; - /* no need for update_refs() if object already gray */ - } else { - excess_ref = 0; - update_refs(object); - } - raw_spin_unlock(&object->lock); - - if (excess_ref) { - object = lookup_object(excess_ref, 0); - if (!object) - continue; - if (object == scanned) - /* circular reference, ignore */ - continue; - raw_spin_lock_nested(&object->lock, SINGLE_DEPTH_NESTING); - update_refs(object); - raw_spin_unlock(&object->lock); - } + pointer_update_refs(scanned, pointer, 0); + pointer_update_refs(scanned, pointer, OBJECT_PERCPU); } raw_spin_unlock_irqrestore(&kmemleak_lock, flags); } From patchwork Wed Jul 31 02:54:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Tikhomirov X-Patchwork-Id: 13748011 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 6AC01C3DA7F for ; Wed, 31 Jul 2024 02:56:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08DA56B0085; Tue, 30 Jul 2024 22:56:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 03C446B0088; Tue, 30 Jul 2024 22:56:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF7146B0089; Tue, 30 Jul 2024 22:56:04 -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 BF9956B0085 for ; Tue, 30 Jul 2024 22:56:04 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7D042A3674 for ; Wed, 31 Jul 2024 02:56:04 +0000 (UTC) X-FDA: 82398533448.22.40AAA7E Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2092.outbound.protection.outlook.com [40.107.105.92]) by imf14.hostedemail.com (Postfix) with ESMTP id A948410001C for ; Wed, 31 Jul 2024 02:56:01 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=virtuozzo.com header.s=selector2 header.b=oqxFhf+K; spf=pass (imf14.hostedemail.com: domain of ptikhomirov@virtuozzo.com designates 40.107.105.92 as permitted sender) smtp.mailfrom=ptikhomirov@virtuozzo.com; dmarc=pass (policy=quarantine) header.from=virtuozzo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722394518; 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:dkim-signature; bh=ylIcNosXLCsrQL6Zby7xoIxqUyUFerSwRfdsQ1cn3mc=; b=QHoJ2bPw7Rfy2iPX/VtKl66hijQPRzyKlCNFN6mEb0r8ImgujLUhnkLslGYJYl0spe0n+5 kIATJXjwwigh5m2MqxgNGSV+SGYJ8O5vN+FJDBcMHuMkZ0GMF9qCFabXZsEH41ab4J6OQt h4yZaFtuXS1TzSbmsMTxWcSB4t39SZI= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=virtuozzo.com header.s=selector2 header.b=oqxFhf+K; spf=pass (imf14.hostedemail.com: domain of ptikhomirov@virtuozzo.com designates 40.107.105.92 as permitted sender) smtp.mailfrom=ptikhomirov@virtuozzo.com; dmarc=pass (policy=quarantine) header.from=virtuozzo.com; arc=pass ("microsoft.com:s=arcselector10001:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1722394518; a=rsa-sha256; cv=pass; b=V31AqyrqVXH3Lx139BJse291jWY3tHhxYF/0rpAYU2RSK5cwWlrEeb+miZixE+R99MxsrU ZNndiVY9hHZboTuR+LxLhH2NfW/CdIqdvmQiyDv7av9ZXg94Ee+JnC+fwKOTEpIFOlNLfl MRtbhIIvbNW2H106QSNlrDgSgyzNrTU= ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j2FEQaSAQFnqmsSK7w6u6Wps0JfR7/pcCn7ijZKBZ5K/L2E12KgNNWhAuTZYClT6NR384ppi3EcN45LUeMeDKJHjNh/ocyGMLi1YCvdTAK5IvpGp5HRCBmLvi6Z6dccQhPAI5TFIHef3GocWjTFlVsgZzV/akqaXEnOGiihAZTQVyB5CFb+XDaZt0prmHaRZ7Ka9g/feI6Oq9Zk9CfVWg9iuwLxDjq7kGf/G7+mM/OXE7rkrdX5Bc6AMPDGfll2p5mVrCCy6nG9tR/X8AuyXdgpCeJbMI+9wzhaCI4I4CWtIdsFMFFstF8RknlfElpxTHmdhEzP1aHS0wZN65P6TsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ylIcNosXLCsrQL6Zby7xoIxqUyUFerSwRfdsQ1cn3mc=; b=mrpTH+5H8HH+dKjKe9YNh5GEVpeC0l/rdQTJgxZdeEMtwNP6ICf/WTbhduCYwwjd+IYf9wvTIGNCP0RZJxo+/ukesnHzKVxn9C+W7vEnYqewWiws6DSq0aNnelQ4XdpBBa58fRv+OYQYuWAxyKtp7ONyObl5lt8X0uGRetyES65Pb+A7/isqCn/wBuMT3/6RWUReln8gk+PyXYnhXDAJJEujuzLHbS9g2QResF3jclpWUEf3YBKIrt4QaxJzUB9JBDRT3+x1hXS+7+gJBBnMOEjJ2qCe5JD+ElqLvpedAK3P9Ro6SMvwohYDXraukTo7nTPQxBbZqq5aKM9vsUsSog== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=virtuozzo.com; dmarc=pass action=none header.from=virtuozzo.com; dkim=pass header.d=virtuozzo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ylIcNosXLCsrQL6Zby7xoIxqUyUFerSwRfdsQ1cn3mc=; b=oqxFhf+K4ZtFh2rBjKc95dkE1tIp4RAfsRHL5h7VcHHbwp6ah6nGsC6LSvfMWjbBppYGIx6nQaxpTb2QpKhutSnAwr0qGM8gWkNM+Y/yqrq9yEAhqmzAa6twsrJsETj4/sRIetZZvqMJCKRRXfMNRNmGW/wjVNVSF0RjNpMHIXlFjqPoG6abt11qpQHGAvyYonJAlufjy/m8CUFavHl4pzZmLmowIlBLHUqWtHVadzIbo1rDkyUm/i10PAR2sRmZWmEpWxK0hDm9ojHdzX1bxbJdUcU35lUuF00RCaOfbzivi1NdHKRXws2B+2PYKDdF/4l6ox3rXC6OlvUSlQUutQ== Received: from DU0PR08MB9003.eurprd08.prod.outlook.com (2603:10a6:10:471::13) by AM8PR08MB6483.eurprd08.prod.outlook.com (2603:10a6:20b:315::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.21; Wed, 31 Jul 2024 02:55:48 +0000 Received: from DU0PR08MB9003.eurprd08.prod.outlook.com ([fe80::7261:fca8:8c2e:29ce]) by DU0PR08MB9003.eurprd08.prod.outlook.com ([fe80::7261:fca8:8c2e:29ce%4]) with mapi id 15.20.7828.016; Wed, 31 Jul 2024 02:55:48 +0000 From: Pavel Tikhomirov To: Catalin Marinas , Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yongjun , Chen Jun , Aleksandr Mikhalitsyn , Pavel Tikhomirov , kernel@openvz.org Subject: [PATCH v2 2/2] kmemleak-test: add percpu leak Date: Wed, 31 Jul 2024 10:54:10 +0800 Message-ID: <20240731025526.157529-3-ptikhomirov@virtuozzo.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240731025526.157529-1-ptikhomirov@virtuozzo.com> References: <20240731025526.157529-1-ptikhomirov@virtuozzo.com> X-ClientProxiedBy: SI2PR02CA0033.apcprd02.prod.outlook.com (2603:1096:4:195::20) To DU0PR08MB9003.eurprd08.prod.outlook.com (2603:10a6:10:471::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR08MB9003:EE_|AM8PR08MB6483:EE_ X-MS-Office365-Filtering-Correlation-Id: a274d873-2cae-4736-eec2-08dcb10c47a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|376014|52116014; X-Microsoft-Antispam-Message-Info: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H0dYsXsGV2rA8WYF/Sk+z/B7J070J/R4fhEJfrPMICOjIEINVBpg3u5Y663jbiH/cWNwxPlVkBLbsaWpA+OB55mvIGTnqxmOg95pzdij+UDBEAXm9KCPSL0CqYBcEeM7NY8szcsSuH3MB1n1LyymyUsbRRPOJNGUaAHkqhqD4SorR+FMUjcOHxJbK4VN7OP98Snz0lrgCusLhVRJNx122ae8CPbB7Ry7WP5Dbg0DOHlX+9sj/rTgI61G32/SKEtMVdmq+I3SOjD3GmHy2naKJcDkzUL3U9oMsSY6tJY6wfmw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU0PR08MB9003.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(376014)(52116014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oMtIFUlObcbRQ+3gBTGXnK0IMEOoJMqJR+i2292dLUY6yUmfwyLHJhSzDlQjByBoasdtZAQd92s+UfCJNXojhdglKseXfkzUT4DwBpcGLmEFpSvdjFcd4ZRudJgMcrgtogAbPU+hWRhwVoldo0nRM4Zyry3mLHH/mTYiez4fcFmPolDlsN2qVBpsIbudkafgkwB4sfhhDJCaRbYnljLPz5RenSUEZEwa43GiwikR4w0n98NUHz47O3HP3y1N61oA0q85GZp7tLRx720hVC+dqq013x8vdVYKJlbloBxa8QdvFpFBXwVW3xvXie4dUdSY9kGq1KL3iXHz3RZcz1cLL0c65pVnlmT4WNxE6+k8tXfT0Zk2OWoQsi+HkBeFPDMrCST40PqVIhgyuMxPLK96k8y6Ph7tLWpQSe3K95e0Yj0uwjJmr1C0xqj7nTZ6nluKuNZa/1GaVolqcZQELH7Q2Xl2JLUbMf5gMLKXvwiTbeHZYHNLhKb7rW7BYs6DTw8SliQ7DBIkgEkWxvq5UjWRE5NVmqIddi1Gm+UIec0BWSEtlh6OWS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GWUhCynmTQOFbHTULojb6MyB4shCbzWWMAqVRwHd4ImxClBAHQ== X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a274d873-2cae-4736-eec2-08dcb10c47a6 X-MS-Exchange-CrossTenant-AuthSource: DU0PR08MB9003.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Jul 2024 02:55:48.0249 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vsxJwujtg/zUOEvAWO49yX5oZ/BiYyZ3b5JAkFEiC7CxwODBs/ujc+35IIiPflzDbq859YpO95L1xHW9FrEqRIYUnqf+cD/I4pLdSdn2W/A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6483 X-Stat-Signature: ojkdiqr5eurz9ar3kuctxmb6umn6okzt X-Rspam-User: X-Rspamd-Queue-Id: A948410001C X-Rspamd-Server: rspam02 X-HE-Tag: 1722394561-185057 X-HE-Meta: U2FsdGVkX18b08pPQHMTstQ/TfejAPZ0sZR6625Fu9tavI+oXSlRIFmOI/P57H/iH6BcJqBDBfDEmXrdnpTiutE3bYEeLGY+e7E6X93ZRvUK8J4FvkzOitjciKV1ccs63SlqCOg8Yg+92JP31eTBfCjOnwEWiLgIQfp2pD4j0sWu5xHC0CF/L0nExtAg7kzsAaXqS50Gvz/pgG1nmlIA7EhI4vM5ij7Q0WQYjiI3oBf/G55wcphNaSqEJQtMlQciRjs2KYIbh8pgvge9MCgzLap1ImabPfoPYhcr/K90qgZ6NEDJTlVdC6b3UfS/0vJZGOGi2RaTsVdMfIFzUI2/hqQA1mBz5SvJ6hHhVxrMKSbwYQehY4ENNuDpTlyqi4KzB0ywDZx/lePLbAcaIu+TvoUkV3Pk/YXpeZCcVoxKojod6qiT8idminhvDHJTRdUOfmWW/JwdyyuNyhNCx4azD6C2nMmZ0qOuRioi0pQatfbioeeJGVkCfUgrDu522IqzmYNGXIope3/lvoheTQP8aTzM5yXYQtJ282LR4wR1DzJS4QrTjusPK3q2N8kKOfdp23BKbvioXvdcoU/PjYqmTdEL/iww/iv1/IBkbvke8W/tSHyXwdDeBpran9q031xZdnxXM1/8ktL0Xv8Wr/Luu5RrEeuBvmJzaN2TGdUEg00gIVs+hSvqOCGaTEuuxr2lmWmicRS3AZIkkxV1BLhY2tY1HybfpQbby44oRaUVlRGxW5tfmDqk7HAeCZj0JkMtNjV6O+5Z7G71daqlB+517hBncJ+QQK/iRGI28dBc7J4GqXuytyvkuegs4emdU2hoOcs9zjPPJ+tS8fK0yOVwG+kix39AuBP01lExELxkZUdF6Xz6ub6vGnw7AmaPNVpW/o7qkpzkV5Tep+xYRzzHNVj1M4aPvLdCx3Jgo4BfNnvzscLQGBbG3v65SLws5UsR2dYq+c+waIKSW+L/8Zj Dx/0pDtN n0hXA2dGX3kjZP9Y7Zf9UGy5g2xC6a+yPdS8H+Kuv4XoJtPi32gec5/K0ZOg57u5A+Fm4XBHZ+s+dKAWF9IqqnbieYlvCeZsW+JVyALwQRMcaMnoz5kdRkRc/dX/X0wVEsWitXnhFjuE+7d89D6kUG+p7sY5TwvId+P3yVeQib8cWpSSzeSlasVdnL+1LEJ2Hon4DqoVKHK/mlnR3zgTIlPP55XIrYSoRYZpVTp2ODlOzTYwaAk1mQS8/jjr6aOIHhOeM3Tk0wx9hIpDQG3EJLEy0gA5+Sc2F5Et+cTZS6840n1WOtKyvnIDliAmBcTxJK8P+g3dEinuhSVutHQfatMBeF3Az0k1c7OXnPYpuTwyydjMu9mkuyjjuspdU2Vl5/qSj3yQs4SvQbh6bWbIvg33eVg== 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: Add a per-CPU memory leak, which will be reported like: unreferenced object 0x3efa840195f8 (size 64): comm "modprobe", pid 4667, jiffies 4294688677 hex dump (first 32 bytes on cpu 0): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace (crc 0): [] pcpu_alloc+0x3df/0x840 [] kmemleak_test_init+0x2c9/0x2f0 [kmemleak_test] [] do_one_initcall+0x44/0x300 [] do_init_module+0x60/0x240 [] init_module_from_file+0x86/0xc0 [] idempotent_init_module+0x109/0x2a0 [] __x64_sys_finit_module+0x5a/0xb0 [] do_syscall_64+0x7a/0x160 [] entry_SYSCALL_64_after_hwframe+0x76/0x7e CC: Wei Yongjun CC: Chen Jun Signed-off-by: Pavel Tikhomirov Acked-by: Catalin Marinas --- samples/kmemleak/kmemleak-test.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/kmemleak/kmemleak-test.c b/samples/kmemleak/kmemleak-test.c index f7470ed85a79f..544c36d51d561 100644 --- a/samples/kmemleak/kmemleak-test.c +++ b/samples/kmemleak/kmemleak-test.c @@ -79,6 +79,8 @@ static int kmemleak_test_init(void) per_cpu(kmemleak_test_pointer, i)); } + pr_info("__alloc_percpu(64, 4) = %p\n", __alloc_percpu(64, 4)); + return 0; } module_init(kmemleak_test_init);