From patchwork Wed Feb 8 07:35:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 13132539 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 4D6A1C636D3 for ; Wed, 8 Feb 2023 07:36:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E50B96B007E; Wed, 8 Feb 2023 02:36:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E00206B0080; Wed, 8 Feb 2023 02:36:56 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C7ADA6B0081; Wed, 8 Feb 2023 02:36:56 -0500 (EST) 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 B544A6B007E for ; Wed, 8 Feb 2023 02:36:56 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 824DF140D15 for ; Wed, 8 Feb 2023 07:36:56 +0000 (UTC) X-FDA: 80443318032.07.581BF0D Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2062.outbound.protection.outlook.com [40.107.92.62]) by imf28.hostedemail.com (Postfix) with ESMTP id 94CF4C000C for ; Wed, 8 Feb 2023 07:36:53 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=qPvQNPFi; spf=pass (imf28.hostedemail.com: domain of bharata@amd.com designates 40.107.92.62 as permitted sender) smtp.mailfrom=bharata@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675841813; 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=IVShu4+QzQHsTFEmQ4HZTu3XYpXXfIe/NUivxg9UnAs=; b=hgIMkt67FuRrtNT69t7OwcHfP7HzSgq5A15UbSkUd2J3dwOsCE4PUAN01SS7rJgKS9/NYO w/MckGL0bjcxptY7CaqhXfbsD39CRsPed848tIx+2fC29lj0rO+CS8u/A7PGi4h2Q3JZdy M9Jh3XZo4IOMqWLAik98xh0X/svDs7g= ARC-Authentication-Results: i=2; imf28.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=qPvQNPFi; spf=pass (imf28.hostedemail.com: domain of bharata@amd.com designates 40.107.92.62 as permitted sender) smtp.mailfrom=bharata@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1675841813; a=rsa-sha256; cv=pass; b=WvTYfIvzak+P/2sN4LBVWR4NsvyHJb01fAhLl9wuaH5iQTAhJPqQ3kgkPIP7L4frdPtxZ9 NcR17tNTxdezFgX9S1kx+xt9oWCQNIK5s5wWXCul3t2H9wbQbS5SawS9T2urW8OLrVWhVG u14jALZvHX0ABOj5iw+K39FWA4eC7SE= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fX+iaam+5szrGbaySOxlfuSb7niha0Wg+a+b4Xqg+HbVgPavlaFrvFlAcnS3BxfvkPy4Wyh2nzPhgFR54wYFNSOV1tkV4tzbNC1ab4lMhAO9gEG1bfQ3Yoy76mWt4UM8W1ixdcxy/6hx4qDFP9M6a/7/y+jc62TG4x9U1gI1Pb4DtBU03H+Bxo/VS2pAc2FqAdITfvJ6DGSnu2g9MOM57ZB279pi9iG1kA8v1Zqvf1X2YEoFWj2G3WHGhEDh4KijijHdieco0LbIyLLD+Rw4zCYRn41qJlPvxs3pW0ZKQ2PZdBtvutQtl2LqTM4yJZU7wj4uthQJRGCH9mgUy/oPJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=IVShu4+QzQHsTFEmQ4HZTu3XYpXXfIe/NUivxg9UnAs=; b=APentNT8N3Ykv7fIPXf+KWpZ8hD+LQfcsSDOyT535gDotgHZ7X6/2FDMEwvKH5fFLsw/SF640iO8XjM1AopT1Jr4Uwxm1Ra8zUMBpY/MPBpFygul+NmKPa81RPft3L3/cckcrl13GTliRa3hjX43Eeh/GG2jiZzQcLwLbetpvigF/Ykmr4leKZyYH48GIQtJv0Bj2Du+0XCnaPpCd13Ai196zuqApLDkL+K3o6arLief5U9Ii0BXKyfFjXIZD8D1ybnqRiljT5Am39hlXUgheDiPkjNR2oBUXeSqhvyLGniLJHLXa7k1rDw+xafCQ5J4UK8oYPSvAcaDoBov8n3FHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.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 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=IVShu4+QzQHsTFEmQ4HZTu3XYpXXfIe/NUivxg9UnAs=; b=qPvQNPFiYKAMqgQNyLOGu4M9PWS6NyZXYyiU7VWz2J5rKhDSnnyIRyQuY0eTx2InKPM5f2RWlOkjRPs4zm/sndZ5rkjPN+UqUYCmEd7i8xtlUfKPE0u0YGVSOjMemr2qtuEZpUUL3FF+OXFqBP7+3USckDjQ6CvazdqBRqyj7rk= Received: from BN0PR03CA0023.namprd03.prod.outlook.com (2603:10b6:408:e6::28) by IA0PR12MB8328.namprd12.prod.outlook.com (2603:10b6:208:3dd::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17; Wed, 8 Feb 2023 07:36:51 +0000 Received: from BN8NAM11FT059.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e6:cafe::c0) by BN0PR03CA0023.outlook.office365.com (2603:10b6:408:e6::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6086.17 via Frontend Transport; Wed, 8 Feb 2023 07:36:51 +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=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT059.mail.protection.outlook.com (10.13.177.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6086.17 via Frontend Transport; Wed, 8 Feb 2023 07:36:51 +0000 Received: from BLR-5CG1133937.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 8 Feb 2023 01:36:46 -0600 From: Bharata B Rao To: , CC: , , , , , , , , , , , Bharata B Rao Subject: [RFC PATCH 5/5] x86/ibs: Delay the collection of HW-provided access info Date: Wed, 8 Feb 2023 13:05:33 +0530 Message-ID: <20230208073533.715-6-bharata@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230208073533.715-1-bharata@amd.com> References: <20230208073533.715-1-bharata@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT059:EE_|IA0PR12MB8328:EE_ X-MS-Office365-Filtering-Correlation-Id: f743052a-3f22-48a8-74c3-08db09a73e62 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9iibJvhHoow1en+liIen4YbhYWJUdjq/E2YIyw3XoGlVLHubOMYyjwcLOGee0oZSjlBXe5M2+GBy8eWVmP21ReKnTmy7NUfRYSO5fwTEa0Sqtzzvgcd613A9XNTUr7cbn2JSDqOR9UJyErTeCOBE4732KTeLUQBpwxBxAZIlhKc+rOFSRLJ7EHrt0TLqWdE7hmUOtANit6fuXCgW154H3+PIO5cWp9t4+2ArGyiGC5rfRi5MWXjoxfba4RDTwohbqGngL7/ulRdhUkON7i1HSAvzstZpJ/FMYoN5/L9C8lx75XdpXLQGsSV5h4HAhNLZhgWaTxLS957MCcSA1prIjjGuOiQRW6aK+LHWty1j8LaOe2RoQSp4fZk4Glh8CnZ1+pDov3cHnFjRxI5/aO23FFJveKWffRXQMZRbyGCWCusXZa8G9xw04h+h0KTRDq7j3ukeVm4lraVvfbCZusRa9HGmlTdM2joTOasXXVGr5Kygxg/H5YancHQgP/nbShYUDnd6QESpgntuhpK9PA9SHePharJvB8WFQBl9RpZFI5fymyPxHiK+VRen2rduaZ/07G8HzNHEJXI2BfDP0aZiF0NGNF1gediDAr4Gpoe+HfPY8Qqw4tgoCwvdNQUzRtZhiJIQ16QlmVO5qWJk7JVPCkDWIrGg4yItBYfuOuG5NTXBZfSgfokdwGVSMPWkEWJfufkt77J+rDLE5Kn22y3s9Fb6Z1DSDwMnb37sFwpJNM+wowfkXqoWT9VWJIP9S+h9 X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(346002)(136003)(39860400002)(396003)(376002)(451199018)(40470700004)(36840700001)(46966006)(5660300002)(16526019)(86362001)(7416002)(81166007)(356005)(26005)(186003)(8936002)(6666004)(2906002)(82740400003)(8676002)(82310400005)(70206006)(70586007)(4326008)(41300700001)(36860700001)(316002)(40480700001)(426003)(2616005)(1076003)(40460700003)(478600001)(47076005)(7696005)(54906003)(110136005)(36756003)(336012)(83380400001)(36900700001)(2101003);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Feb 2023 07:36:51.3416 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f743052a-3f22-48a8-74c3-08db09a73e62 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=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT059.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB8328 X-Stat-Signature: mohmybd8kgzfwhgyses8whp1fks3kjbk X-Rspam-User: X-Rspamd-Queue-Id: 94CF4C000C X-Rspamd-Server: rspam06 X-HE-Tag: 1675841813-457443 X-HE-Meta: U2FsdGVkX18T+zplj2Gu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svGq0wWdHcc3VcZoQ/QRRA0V65rFnPlrlw3Xt1I7enRkqlSGKBkvY7VHrMVUMQaNiaf+L2Tyjw40xooQazJv6qVpVyP7s26dDpUBlGTZVDrp1TBnWbzg0VXCVqKwBH3PqWr9dMJrN+/ioI8dBaaz+o4sfgNUuuSPMuxIKa5lwwymS4nDrymhlVRWv9K390HJI2y+4r5YbsugWO3u41lDtR7ALR1AhfXcS7CHKQPuyQvmx5vV0V4HOhvNQM8sOyfRbxIY8/lF9jRyQyUE8Bp/jypzo2w= 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: Allow an initial delay before enabling the collection of IBS provided access info. Signed-off-by: Bharata B Rao --- arch/x86/mm/ibs.c | 18 ++++++++++++++++++ include/linux/mm.h | 2 ++ include/linux/mm_types.h | 3 +++ kernel/sched/debug.c | 2 ++ kernel/sched/fair.c | 3 +++ 5 files changed, 28 insertions(+) diff --git a/arch/x86/mm/ibs.c b/arch/x86/mm/ibs.c index a479029e9262..dfe5246954c0 100644 --- a/arch/x86/mm/ibs.c +++ b/arch/x86/mm/ibs.c @@ -16,6 +16,21 @@ struct ibs_access_work { u64 laddr, paddr; }; +static bool delay_hw_access_profiling(struct mm_struct *mm) +{ + unsigned long delay, now = jiffies; + + if (!mm->numa_hw_access_delay) + mm->numa_hw_access_delay = now + + msecs_to_jiffies(sysctl_numa_balancing_access_faults_delay); + + delay = mm->numa_hw_access_delay; + if (time_before(now, delay)) + return true; + + return false; +} + void hw_access_sched_in(struct task_struct *prev, struct task_struct *curr) { u64 config = 0; @@ -28,6 +43,9 @@ void hw_access_sched_in(struct task_struct *prev, struct task_struct *curr) if (!curr->mm) goto out; + if (delay_hw_access_profiling(curr->mm)) + goto out; + if (curr->numa_sample_period) period = curr->numa_sample_period; else diff --git a/include/linux/mm.h b/include/linux/mm.h index 8f857163ac89..118705a296ef 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1397,6 +1397,8 @@ static inline int folio_nid(const struct folio *folio) } #ifdef CONFIG_NUMA_BALANCING +extern unsigned int sysctl_numa_balancing_access_faults_delay; + /* page access time bits needs to hold at least 4 seconds */ #define PAGE_ACCESS_TIME_MIN_BITS 12 #if LAST_CPUPID_SHIFT < PAGE_ACCESS_TIME_MIN_BITS diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 9757067c3053..8a2fb8bf2d62 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -750,6 +750,9 @@ struct mm_struct { /* numa_scan_seq prevents two threads remapping PTEs. */ int numa_scan_seq; + + /* HW-provided access info is collected after this initial delay */ + unsigned long numa_hw_access_delay; #endif /* * An operation with batched TLB flushing is going on. Anything diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 1cf19778a232..5c76a7594358 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c @@ -342,6 +342,8 @@ static __init int sched_init_debug(void) &sysctl_numa_balancing_sample_period_max); debugfs_create_u32("access_faults_threshold", 0644, numa, &sysctl_numa_balancing_access_faults_threshold); + debugfs_create_u32("access_faults_delay", 0644, numa, + &sysctl_numa_balancing_access_faults_delay); #endif debugfs_create_file("debug", 0444, debugfs_sched, NULL, &sched_debug_fops); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 1b0665b034d0..2e2b1e706a24 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1097,6 +1097,7 @@ unsigned int sysctl_numa_balancing_sample_period_def = 10000; unsigned int sysctl_numa_balancing_sample_period_min = 5000; unsigned int sysctl_numa_balancing_sample_period_max = 20000; unsigned int sysctl_numa_balancing_access_faults_threshold = 250; +unsigned int sysctl_numa_balancing_access_faults_delay = 1000; /* * Approximate time to scan a full NUMA task in ms. The task scan period is @@ -3189,6 +3190,8 @@ void init_numa_balancing(unsigned long clone_flags, struct task_struct *p) if (mm_users == 1) { mm->numa_next_scan = jiffies + msecs_to_jiffies(sysctl_numa_balancing_scan_delay); mm->numa_scan_seq = 0; + mm->numa_hw_access_delay = jiffies + + msecs_to_jiffies(sysctl_numa_balancing_access_faults_delay); } } p->node_stamp = 0;