From patchwork Wed Nov 2 02:02:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Leonardo Bras X-Patchwork-Id: 13027670 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 A38DFC4332F for ; Wed, 2 Nov 2022 02:03:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 263E98E0001; Tue, 1 Nov 2022 22:03:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1EC8B6B0074; Tue, 1 Nov 2022 22:03:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 03F118E0001; Tue, 1 Nov 2022 22:03:46 -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 E1E036B0073 for ; Tue, 1 Nov 2022 22:03:46 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BB5B71C62D0 for ; Wed, 2 Nov 2022 02:03:46 +0000 (UTC) X-FDA: 80086856052.19.60DE6B6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 601B0160002 for ; Wed, 2 Nov 2022 02:03:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667354625; h=from:from: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=CMSAt3GthE2zWUBTJjLiVIVQICwCKfwnNgpg1Ix0oWM=; b=VTYqX+oBfJTKfIr/hUEjVrAwQ5eU1flJmRBcaqpCDAKndBHpTohSyN9M/xdqQPVsW0W1n9 sR6WEXNoTSgFCFsSuzry8kmWI1ObrPUQvEohVE1R1FdBJT3vmbpLjYTNA7xHTolSyUqLP/ rvl5DBdMR/Df5t2j3mPMmdGk5H0+X0U= Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-453-9JVLCAhkNImbkOgT3e7H9w-1; Tue, 01 Nov 2022 22:03:44 -0400 X-MC-Unique: 9JVLCAhkNImbkOgT3e7H9w-1 Received: by mail-ot1-f72.google.com with SMTP id l31-20020a9d1b22000000b0066c48e9249fso4641092otl.5 for ; Tue, 01 Nov 2022 19:03:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CMSAt3GthE2zWUBTJjLiVIVQICwCKfwnNgpg1Ix0oWM=; b=IH19u4N8MULdQckAz9WKT39XdybSvFRzpa0nO91ydQ4qeZtiCvPv+vESMOqSTdGThL VrOgVCiVo0rVSUZ7Y8++SVTMadZLfdIRl1yvPk+0/ToTTS04xiSMVmIV+lBb2n+TvALL AaLgELsvVB2WhqAXuc+UP7Y0erxVTVI1E4e1AZUQBf8cLieHkcQ3gyCplcJUhutc5N3z mEOxRxetCtFIUCyV+9Q6DOlFzyZs9wowUPja/OhH/VTF7HwLWQH/lSOAB1CMLXsfwsej eASpoCy6dIno3RIc3Jmfzlxjb4btC11sx88wHLNfaLjGZU+bs1J9OXkmoPtEiU1z1ZiR Q+jQ== X-Gm-Message-State: ACrzQf2z8UM89eZD38l130f0UnFrlzGme9/xBUjHzgh0WAtiV3RgYFco OYG8RZhKdc+V0md2jEMEQ97FGaMtK4Idq4QLyqXUA6BCwWE0y+vqz9fbRrmnfnPqvhdhoyhMdbQ QYK/WGd8gw1E= X-Received: by 2002:a05:6870:d250:b0:13b:3100:abcc with SMTP id h16-20020a056870d25000b0013b3100abccmr13089122oac.3.1667354624067; Tue, 01 Nov 2022 19:03:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5zv2uj8jD1EUkakgeYhALybaybY7reFpZn0f4powVIbb55KSIq40hrRxQHM4RpX4sgR1KnYw== X-Received: by 2002:a05:6870:d250:b0:13b:3100:abcc with SMTP id h16-20020a056870d25000b0013b3100abccmr13089090oac.3.1667354623748; Tue, 01 Nov 2022 19:03:43 -0700 (PDT) Received: from LeoBras.redhat.com ([2804:1b3:a802:1099:7cb2:3a49:6197:5307]) by smtp.gmail.com with ESMTPSA id h15-20020a9d6f8f000000b00665919f7823sm4526624otq.8.2022.11.01.19.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Nov 2022 19:03:43 -0700 (PDT) From: Leonardo Bras To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Johannes Weiner , Michal Hocko , Roman Gushchin , Shakeel Butt , Muchun Song , Andrew Morton , Frederic Weisbecker , Leonardo Bras , Phil Auld , Marcelo Tosatti Cc: linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH v1 1/3] =?utf-8?q?sched/isolation=3A_Add_housekeep=C3=ADng?= =?utf-8?q?=5Fany=5Fcpu=5Ffrom=28=29?= Date: Tue, 1 Nov 2022 23:02:41 -0300 Message-Id: <20221102020243.522358-2-leobras@redhat.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221102020243.522358-1-leobras@redhat.com> References: <20221102020243.522358-1-leobras@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667354626; 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=CMSAt3GthE2zWUBTJjLiVIVQICwCKfwnNgpg1Ix0oWM=; b=bJnxdkXiPCyXYTgmhIC966MGx1wZWDroy5HqThE3nEx6Ow52XCOL/7sRyz7zTAy5emECny AoO7eBoej6InQGvHfZlor+MvGrOz9j6YfS9At3z+O7Dl72tnFStHUNLQcoKzV+tggiPBHl Ld9EKdtlMITIAPm+FNW5vQ2fLRynuA8= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VTYqX+oB; spf=pass (imf08.hostedemail.com: domain of leobras@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=leobras@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667354626; a=rsa-sha256; cv=none; b=njGM81OxSOqWo9JtPNF609VM6XxAmS5ifbgoyR3r3SZa2FcZdwODQmfT2/+3RNG9sE78qw 7z97SqyPJJbn4P7scBJH+HJVlhtlzQks4zCzRcaoKN1XY0sT36j+bBN802YWhCciax4jeM CfVkVCzubAVwHhElAjGuW54+vr/9liY= X-Stat-Signature: hyr7jqqh7xrkmtbt4dob7xyuyi1wbuux X-Rspamd-Queue-Id: 601B0160002 X-Rspamd-Server: rspam06 X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=VTYqX+oB; spf=pass (imf08.hostedemail.com: domain of leobras@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=leobras@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1667354626-229162 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: As of today, there is a function called housekeepíng_any_cpu() that returns a housekeeping cpu near the current one. This function is very useful to help delegate tasks to other cpus when the current one is isolated. It also comes with the benefit of looking for cpus in the same NUMA node as the current cpu, so any memory activity could be faster in NUMA systems. On the other hand, there is no function like that to find housekeeping cpus in the same NUMA node of another CPU. Change housekeepíng_any_cpu() into housekeepíng_any_cpu_from(), so it accepts a cpu_start parameter and can find cpus in the same NUMA node as any given CPU. Also, reimplements housekeepíng_any_cpu() as an inline function that calls housekeepíng_any_cpu_from() with cpu_start = current cpu. Signed-off-by: Leonardo Bras --- include/linux/sched/isolation.h | 11 ++++++++--- kernel/sched/isolation.c | 8 ++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h index 8c15abd67aed9..95b65be44f19f 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -20,7 +20,7 @@ enum hk_type { #ifdef CONFIG_CPU_ISOLATION DECLARE_STATIC_KEY_FALSE(housekeeping_overridden); -extern int housekeeping_any_cpu(enum hk_type type); +extern int housekeeping_any_cpu_from(enum hk_type type, int cpu_start); extern const struct cpumask *housekeeping_cpumask(enum hk_type type); extern bool housekeeping_enabled(enum hk_type type); extern void housekeeping_affine(struct task_struct *t, enum hk_type type); @@ -29,9 +29,9 @@ extern void __init housekeeping_init(void); #else -static inline int housekeeping_any_cpu(enum hk_type type) +static inline int housekeeping_any_cpu_from(enum hk_type type, int cpu_start) { - return smp_processor_id(); + return cpu_start; } static inline const struct cpumask *housekeeping_cpumask(enum hk_type type) @@ -58,4 +58,9 @@ static inline bool housekeeping_cpu(int cpu, enum hk_type type) return true; } +static inline int housekeeping_any_cpu(enum hk_type type) +{ + return housekeeping_any_cpu_from(type, smp_processor_id()); +} + #endif /* _LINUX_SCHED_ISOLATION_H */ diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 373d42c707bc5..6ebeac11bb350 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -36,22 +36,22 @@ bool housekeeping_enabled(enum hk_type type) } EXPORT_SYMBOL_GPL(housekeeping_enabled); -int housekeeping_any_cpu(enum hk_type type) +int housekeeping_any_cpu_from(enum hk_type type, int cpu_start) { int cpu; if (static_branch_unlikely(&housekeeping_overridden)) { if (housekeeping.flags & BIT(type)) { - cpu = sched_numa_find_closest(housekeeping.cpumasks[type], smp_processor_id()); + cpu = sched_numa_find_closest(housekeeping.cpumasks[type], cpu_start); if (cpu < nr_cpu_ids) return cpu; return cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask); } } - return smp_processor_id(); + return cpu_start; } -EXPORT_SYMBOL_GPL(housekeeping_any_cpu); +EXPORT_SYMBOL_GPL(housekeeping_any_cpu_from); const struct cpumask *housekeeping_cpumask(enum hk_type type) {