From mboxrd@z Thu Jan 1 00:00:00 1970 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 A3D48C35FEB for ; Tue, 17 Sep 2024 07:05:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 192CB6B0088; Tue, 17 Sep 2024 03:05:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 142DA6B0089; Tue, 17 Sep 2024 03:05:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F25636B008A; Tue, 17 Sep 2024 03:05:27 -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 CE8E46B0088 for ; Tue, 17 Sep 2024 03:05:27 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 80E8CA7AC8 for ; Tue, 17 Sep 2024 07:05:27 +0000 (UTC) X-FDA: 82573344294.27.37A7532 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) by imf30.hostedemail.com (Postfix) with ESMTP id 6BA9B80011 for ; Tue, 17 Sep 2024 07:05:25 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b="NNiy58/c"; spf=pass (imf30.hostedemail.com: domain of mhocko@suse.com designates 209.85.128.48 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1726556615; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9ILf67Y81lASSuXGrTQfS2z5An5s8u2dCx//Qru/Z7g=; b=KSEhrW0NBxCXLIkv9OtthQxwkB7HLEvQZmIgyLNPKp65ZdJm97/4gIGmK7OLreiyvzU+Hg JPckGeu3JpQkTsq6yHwDVUns8aT3F6W03J8O1NZcgIfeuPhQL39ETQX33hISbaq6Iq8Yec wV2o6DtLLLE6frOODm0QLyUyoXXXlus= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1726556615; a=rsa-sha256; cv=none; b=f5yVlNOLG06fcaPcs81GSIl0NSw1HAtoaWy20t4y1LzXlhYJl2+bFUnRP6TmgNDBLrU78v 5fhoUKds1hlDchxJMAjSwoModIVJ+pXby1o+PIAbmvIxK+l8shBC39T98BwteySgC3EENs kUfDZDUn5NIEdVG1Y0Rv31hGT9mw0is= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=suse.com header.s=google header.b="NNiy58/c"; spf=pass (imf30.hostedemail.com: domain of mhocko@suse.com designates 209.85.128.48 as permitted sender) smtp.mailfrom=mhocko@suse.com; dmarc=pass (policy=quarantine) header.from=suse.com Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-42cb6f3a5bcso53516025e9.2 for ; Tue, 17 Sep 2024 00:05:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1726556724; x=1727161524; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=9ILf67Y81lASSuXGrTQfS2z5An5s8u2dCx//Qru/Z7g=; b=NNiy58/ccoz3X+tK4IMovnYT9Z7CC1iGxmDaPjdHv+runAhKs+/KL1O9rvpSZzNGh0 gqu9m4yRmSOPuazipyQhLAEM+G4UKKNPUmHvtn2LfPveid/2Og1Jwm7GxqRSjQwG6lJa mKF3MM2mohGfNWsdGPu9gYZUTypxj83nM9XJ06M16nfE/5SaYDJ2/LjStwprfaDMnsK2 QCmL34MVA/z7EYFZnbMX+A6/1VYQUZMBKA89zz6IRgurXABLlxv+1v/Q0bJ3zJp8o1LO AfxSkrl9XledAuyh66L5GW+M2Mp4YpHR5dujVhKGBARBimeC1MVQEWzlOCyiwBooUbhA Wz3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726556724; x=1727161524; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9ILf67Y81lASSuXGrTQfS2z5An5s8u2dCx//Qru/Z7g=; b=hQtkI27YsAOyh/rFuspVFv1jvrqI9KF4yFWCbMr938ghggT4PkWSvFc/f8yeVFnttv 4x+RzZWZ77+jkT+n18PzbpPMVN5RHKMITiZB4ho9VMn/AdZrUUqBToegb7PaMMXpo5qe XrqozO5zAqTzd6XkMSIRF2PTntNwxoDEZzzfb3hO2nOtnJvndbXXUqEGlCnrQNn5eae0 l9GsOajIWx27Fs8WCzX8cjcDL1XN0gtklWEg5oHGYyg9gbqPG3hHPuuc+o6/UyLfFRIu ywealOJtnDZGTQbY+bPIpDZfmtq+NLufVQyTgsrdDOKsVQzqJOrXjbL24l9o4XfSMBQR jNSQ== X-Forwarded-Encrypted: i=1; AJvYcCUZR1Hw3syek1Dkc2A3eunvI3OQhM4kEzLJRdtoaTZxYnWPnMSXejDgdoD9Afhu7OUWuN0MVK4TAA==@kvack.org X-Gm-Message-State: AOJu0YzSCZktqA3meLI3mCgTKRXarOZcQJWegjhMv9uARTJh8VBEZaq3 o4XXOyftVga/C7VKu7KdAayEJlBrieW0BpHfye5oLGfly/lyDb48/yA9EisXBpo= X-Google-Smtp-Source: AGHT+IH3o/npKUx4YaHbMCjDDrmqsFqTss9Txf7nthZNJj9hxmPQ6MElpiejAbOBFTxY5d2alc+OAw== X-Received: by 2002:a05:600c:3588:b0:42c:bcc8:5882 with SMTP id 5b1f17b1804b1-42d9070a259mr154521055e9.7.1726556723600; Tue, 17 Sep 2024 00:05:23 -0700 (PDT) Received: from localhost (109-81-84-13.rct.o2.cz. [109.81.84.13]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42d9b055052sm129132255e9.9.2024.09.17.00.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Sep 2024 00:05:23 -0700 (PDT) Date: Tue, 17 Sep 2024 09:05:22 +0200 From: Michal Hocko To: Vlastimil Babka Cc: Frederic Weisbecker , LKML , Andrew Morton , Kees Cook , Peter Zijlstra , Thomas Gleixner , linux-mm@kvack.org, "Paul E. McKenney" , Neeraj Upadhyay , Joel Fernandes , Boqun Feng , Zqiang , rcu@vger.kernel.org Subject: Re: [PATCH 12/19] kthread: Default affine kthread to its preferred NUMA node Message-ID: References: <20240916224925.20540-1-frederic@kernel.org> <20240916224925.20540-13-frederic@kernel.org> <4b107fec-e391-4680-9457-b282310b4454@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4b107fec-e391-4680-9457-b282310b4454@suse.cz> X-Rspamd-Queue-Id: 6BA9B80011 X-Stat-Signature: nsjgy8zbzhfpijhhbg1r1bpqjyafdtkr X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1726556725-176015 X-HE-Meta: U2FsdGVkX18k5xIAQKdZrNL28VgY22tt+nPHxaTDZMkt/fS3+Xrs9sg/gLOsiYILlSSfzwqfx+5vixQMKSaFwpNBc1Xz0CtpOtPcJqGK3yuZ/pbZ8O/44orbQ8ORYR+Ti1GIxFMpTt36vsI2nm7uVH3ecYewiaPNeoZa2TuS0PGXrgPhG54SpQTTS/KXoW8dDyC9OXPne2DOYj45JbWtLumU+48nrCMGYSzEDcwWrlM2PYRkE3PwoUsUoluqSpE+FjQ1AWwpppecXaChAP8QhUE5TYeHqeNPFxiyzq7t4j0X+PZC+ugAKBu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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: On Tue 17-09-24 09:01:08, Vlastimil Babka wrote: > On 9/17/24 8:26 AM, Michal Hocko wrote: > > On Tue 17-09-24 00:49:16, Frederic Weisbecker wrote: > >> Kthreads attached to a preferred NUMA node for their task structure > >> allocation can also be assumed to run preferrably within that same node. > >> > >> A more precise affinity is usually notified by calling > >> kthread_create_on_cpu() or kthread_bind[_mask]() before the first wakeup. > >> > >> For the others, a default affinity to the node is desired and sometimes > >> implemented with more or less success when it comes to deal with hotplug > >> events and nohz_full / CPU Isolation interactions: > >> > >> - kcompactd is affine to its node and handles hotplug but not CPU Isolation > >> - kswapd is affine to its node and ignores hotplug and CPU Isolation > >> - A bunch of drivers create their kthreads on a specific node and > >> don't take care about affining further. > >> > >> Handle that default node affinity preference at the generic level > >> instead, provided a kthread is created on an actual node and doesn't > >> apply any specific affinity such as a given CPU or a custom cpumask to > >> bind to before its first wake-up. > > > > Makes sense. > > > >> This generic handling is aware of CPU hotplug events and CPU isolation > >> such that: > >> > >> * When a housekeeping CPU goes up and is part of the node of a given > >> kthread, it is added to its applied affinity set (and > >> possibly the default last resort online housekeeping set is removed > >> from the set). > >> > >> * When a housekeeping CPU goes down while it was part of the node of a > >> kthread, it is removed from the kthread's applied > >> affinity. The last resort is to affine the kthread to all online > >> housekeeping CPUs. > > > > But I am not really sure about this part. Sure it makes sense to set the > > affinity to exclude isolated CPUs but why do we care about hotplug > > events at all. Let's say we offline all cpus from a given node (or > > that all but isolated cpus are offline - is this even > > realistic/reasonable usecase?). Wouldn't scheduler ignore the kthread's > > affinity in such a case? In other words how is that different from > > tasksetting an userspace task to a cpu that goes offline? We still do > > allow such a task to run, right? We just do not care about affinity > > anymore. > > AFAIU it handles better the situation where all houskeeping cpus from > the preferred node go down, then it affines to houskeeping cpus from any > node vs any cpu including isolated ones. Doesn't that happen automagically? Or can it end up on a random isolated cpu? -- Michal Hocko SUSE Labs