From nobody Thu Oct 2 03:32:45 2025 Received: from BYAPR05CU005.outbound.protection.outlook.com (mail-westusazon11010014.outbound.protection.outlook.com [52.101.85.14]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A7802DA76B for ; Tue, 23 Sep 2025 17:49:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.85.14 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758649801; cv=fail; b=dtcKDXzpF7Scy8vR6CqlU+RWbgFOtQ8Af5Trhj5AJUNdfG3aSwQsmv4cQwvP3TdXNZu8f6v4+Iq8iog6euuqUdQKYsZYJjk/+SroHdAwRVkxOHYnmZ39sVWj6i3wnydNy/aqBelwbi7bKIqWoFrLR9rWTfS0hNScKJQmPlrf6kI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758649801; c=relaxed/simple; bh=CfPJWIDGiTuhqlEwmHvATi7RM3HG4WEVkZPum38p3dw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Vgg0czQ6sD2lp4cetSuElLqmIKm9dvfRfqyGFaNXeyYejo8waIPgc1Py+jvvIrf6lgLv06NKBC2ChMnHyDBKu2oG6GvFWNvGP7UpWsXKoJMkTLHSM0Wu0wjmbr8a/hutlfEgvBjllaYHnzV5IfrJBoxfs5sVhXzUsOvVkrKf3Ck= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com; spf=fail smtp.mailfrom=amd.com; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b=bbDl/JX5; arc=fail smtp.client-ip=52.101.85.14 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amd.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=amd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="bbDl/JX5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Wu/nCjwbvsTuse4P1mDFFQ9Wue/aWVK26bI4ikH3bq7kjLHM7y0yFyJ+pxQksu9Z2isz3CAejMsMcZwa6UAdRcAXMDJFHJ9pVJoS63DeCH0ws/fODRO4qYT4nhU9Tk+LZuL8qf0fBgeIdj5d+KY+4tQYd8jdX53qDohqneOAVs/HDXsVlajk7xy7JVYLZFCLFNK9Nljxc5J79TUtv1byzeGAPHkfxqXIq5CTO4y9keXZGttq9M7irkbtGfMQqDNWqC/N+lyqEJPLJogELzbykS8qNeSFB6xRAnv4Ayx+S6wPUsxXCeE+/SzICf53U0Yj5kj8AvZgJEOwG8um1WnRgw== 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=tn8s3EdMLzlUqkrxpuPjkMHYijrpzU78gf7sS2AGTd8=; b=ft40fE2CJaIXsXjXydI0DeDnO8cx77ZyV1igFTpQWPZWu4NcmsG2NIXqG7R+WIg0TPcUN5ciUgpHBKp6vbzjpGyi245h8nWXiDksAN/Q61oUAffsBvm+ZNC3a7n8+rYKuYFLJhOJqr0gt61XohKW9/AvBXw5Rlkdp78pZ2PSs/ri6Rcb4Ub4T7fo8icyKyeL0xK0mj487R9dqgb17o6YYrnWU/kUfL5Iv61bnEsaSYFJniahRp62+xMC5GJNf/A+iOZfYnWXcVi1n2gdweEfzkuXLh8Gh10AUCiTmxdL3r8KoJNn9cL75gBivCFBYHJBGGKiYEmeEIcHZVCybOqZBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux-foundation.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=tn8s3EdMLzlUqkrxpuPjkMHYijrpzU78gf7sS2AGTd8=; b=bbDl/JX5+5cAg8wPeuM8OvXXbEpGXMIgcgS6EPhGK8ZcchoU2oWnbIvT6eKBbrI82sCORzleE88pQfg/ZwADz7ixf2zs/p2s2gxLedg2aGQCfjHN6M3BLNTxQnyUrV13CHdboV+e8vF4snXJEPd3brObET5ooYFD36bnTOTUO7g= Received: from BL1PR13CA0265.namprd13.prod.outlook.com (2603:10b6:208:2ba::30) by DS7PR12MB8291.namprd12.prod.outlook.com (2603:10b6:8:e6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9137.19; Tue, 23 Sep 2025 17:49:49 +0000 Received: from MN1PEPF0000F0E5.namprd04.prod.outlook.com (2603:10b6:208:2ba:cafe::6e) by BL1PR13CA0265.outlook.office365.com (2603:10b6:208:2ba::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9160.9 via Frontend Transport; Tue, 23 Sep 2025 17:49:45 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=satlexmb07.amd.com; pr=C Received: from satlexmb07.amd.com (165.204.84.17) by MN1PEPF0000F0E5.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9137.12 via Frontend Transport; Tue, 23 Sep 2025 17:49:49 +0000 Received: from kaveri.amd.com (10.180.168.240) by satlexmb07.amd.com (10.181.42.216) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.17; Tue, 23 Sep 2025 10:49:40 -0700 From: Shivank Garg To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC V3 9/9] mtcopy: spread threads across die for testing Date: Tue, 23 Sep 2025 17:47:44 +0000 Message-ID: <20250923174752.35701-10-shivankg@amd.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250923174752.35701-1-shivankg@amd.com> References: <20250923174752.35701-1-shivankg@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: satlexmb07.amd.com (10.181.42.216) To satlexmb07.amd.com (10.181.42.216) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MN1PEPF0000F0E5:EE_|DS7PR12MB8291:EE_ X-MS-Office365-Filtering-Correlation-Id: a0223cec-a673-4acc-b9b4-08ddfac99769 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?eRuhbrYZNX9LnUM2tzyCiKOnann/bFO9RT42qi2duvDeCCA07O9tmZfvA1OT?= =?us-ascii?Q?cswGYEYXsJYvLxfKUdSiKAy6F41l3wLJF4MP8nCGT3Rt6fQEsQAhJF09QJ6n?= =?us-ascii?Q?VWRg9gfUyoF2vGuEP8G0zx0DZ+/aV6tazyHqUJyZ3x1h20h8tRP33GeNRjeT?= =?us-ascii?Q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Hakmnw7ZI/RMV/472OZn5QsPXhSPlZdO10K?= =?us-ascii?Q?VbUZapv/nbisvZCzarOfejj/1qDSKxaQ4nVoO/Of0QfMY2yIsSuePXtPZ7Mc?= =?us-ascii?Q?Ib8LHNX7hHiJrEsjJqVbgJk3Yav8QygteXV3U64zJAI0XeIgZp0Ia3jFvTe4?= =?us-ascii?Q?9Ey/tZYI/jkHyNijMzdBq/AbSgVossnqKDFwmUFBM0Vj7/L8f1lZROQJnv/I?= =?us-ascii?Q?uqrbqjt52qzoQ0+5bjGPaGrG/WYQ9qWpCpwwLpUVWSJXj1PjM8oqXk1D+z7X?= =?us-ascii?Q?L4x4YGEyTlKVRN+J7tX/6Kzcvgs6JExzHsto6l3SBAcmWrOjuA6Lj86zdbrc?= =?us-ascii?Q?bTkkireVQOyCx04cJhhsxw6khbOlNJ13D2+/GZGnIIs+iJd8K7kfJQbAUBcF?= =?us-ascii?Q?6UymzMGgyGdeMjKyBzNA2d8cTcF2YfTM9/lfB4m7OZS5CtOq22MBfv3J7d3Y?= =?us-ascii?Q?ihUvByRIsuvTSeC2qKsL45Oq9Iie7rsLn0Ij?= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:satlexmb07.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(82310400026)(36860700013);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2025 17:49:49.1705 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0223cec-a673-4acc-b9b4-08ddfac99769 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[satlexmb07.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MN1PEPF0000F0E5.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8291 Content-Type: text/plain; charset="utf-8" Select CPUs using sysfs For testing purpose only. Signed-off-by: Shivank Garg --- drivers/migoffcopy/mtcopy/copy_pages.c | 76 +++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 3 deletions(-) diff --git a/drivers/migoffcopy/mtcopy/copy_pages.c b/drivers/migoffcopy/mt= copy/copy_pages.c index 68e50de602d6..e605acca39d0 100644 --- a/drivers/migoffcopy/mtcopy/copy_pages.c +++ b/drivers/migoffcopy/mtcopy/copy_pages.c @@ -15,11 +15,37 @@ #include #include =20 -#define MAX_NUM_COPY_THREADS 64 +#define MAX_NUM_COPY_THREADS 32 =20 unsigned int limit_mt_num =3D 4; static int is_dispatching; =20 +static int cpuselect; + +// spread across die +static const int cpu_id_list_0[] =3D { + 0, 8, 16, 24, + 32, 40, 48, 56, + 64, 72, 80, 88, + 96, 104, 112, 120, + 128, 136, 144, 152, + 160, 168, 176, 184, + 192, 200, 208, 216, + 224, 232, 240, 248}; + +// don't spread, fill the die +static const int cpu_id_list_1[] =3D { + 0, 1, 2, 3, + 4, 5, 6, 7, + 8, 9, 10, 11, + 12, 13, 14, 15, + 16, 17, 18, 19, + 20, 21, 22, 23, + 24, 25, 26, 27, + 28, 29, 30, 31}; + +int cpu_id_list[32] =3D {0}; + static int copy_page_lists_mt(struct list_head *dst_folios, struct list_head *src_folios, unsigned int nr_items); =20 @@ -141,6 +167,39 @@ static ssize_t mt_threads_show(struct kobject *kobj, return sysfs_emit(buf, "%u\n", limit_mt_num); } =20 +static ssize_t mt_cpuselect_set(struct kobject *kobj, struct kobj_attribut= e *attr, + const char *buf, size_t count) +{ + int ccode; + unsigned int cpuconfig; + + ccode =3D kstrtouint(buf, 0, &cpuconfig); + if (ccode) { + pr_debug("(%s:) error parsing input %s\n", __func__, buf); + return ccode; + } + mutex_lock(&migratecfg_mutex); + cpuselect =3D cpuconfig; + switch (cpuselect) { + case 1: + memcpy(cpu_id_list, cpu_id_list_1, MAX_NUM_COPY_THREADS*sizeof(int)); + break; + default: + memcpy(cpu_id_list, cpu_id_list_0, MAX_NUM_COPY_THREADS*sizeof(int)); + break; + } + + mutex_unlock(&migratecfg_mutex); + + return count; +} + +static ssize_t mt_cpuselect_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + return sysfs_emit(buf, "%u\n", cpuselect); +} + int copy_page_lists_mt(struct list_head *dst_folios, struct list_head *src_folios, unsigned int nr_items) { @@ -208,7 +267,7 @@ int copy_page_lists_mt(struct list_head *dst_folios, } =20 for (cpu =3D 0; cpu < total_mt_num; ++cpu) - queue_work(system_unbound_wq, + queue_work_on(cpu_id_list[cpu], system_unbound_wq, (struct work_struct *)work_items[cpu]); } else { int num_xfer_per_thread =3D nr_items / total_mt_num; @@ -245,7 +304,7 @@ int copy_page_lists_mt(struct list_head *dst_folios, dst2 =3D list_next_entry(dst, lru); =20 if (per_cpu_item_idx =3D=3D work_items[cpu]->num_items) { - queue_work(system_unbound_wq, + queue_work_on(cpu_id_list[cpu], system_unbound_wq, (struct work_struct *)work_items[cpu]); per_cpu_item_idx =3D 0; cpu++; @@ -276,6 +335,8 @@ static struct kobj_attribute mt_offloading_attribute = =3D __ATTR(offloading, 0664, mt_offloading_show, mt_offloading_set); static struct kobj_attribute mt_threads_attribute =3D __ATTR(threads, 0664, mt_threads_show, mt_threads_set); +static struct kobj_attribute mt_cpuselect_attribute =3D __ATTR(cpuselect, = 0664, + mt_cpuselect_show, mt_cpuselect_set); =20 static int __init cpu_mt_module_init(void) { @@ -293,10 +354,18 @@ static int __init cpu_mt_module_init(void) if (ret) goto out_threads; =20 + ret =3D sysfs_create_file(mt_kobj_ref, &mt_cpuselect_attribute.attr); + if (ret) + goto out_cpuselect; + + memcpy(cpu_id_list, cpu_id_list_0, MAX_NUM_COPY_THREADS*sizeof(int)); + is_dispatching =3D 0; =20 return 0; =20 +out_cpuselect: + sysfs_remove_file(mt_kobj_ref, &mt_threads_attribute.attr); out_threads: sysfs_remove_file(mt_kobj_ref, &mt_offloading_attribute.attr); out_offloading: @@ -314,6 +383,7 @@ static void __exit cpu_mt_module_exit(void) } mutex_unlock(&migratecfg_mutex); =20 + sysfs_remove_file(mt_kobj_ref, &mt_cpuselect_attribute.attr); sysfs_remove_file(mt_kobj_ref, &mt_threads_attribute.attr); sysfs_remove_file(mt_kobj_ref, &mt_offloading_attribute.attr); kobject_put(mt_kobj_ref); --=20 2.43.0