Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp1285922lqp; Fri, 22 Mar 2024 10:17:18 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXyB9/bTSPsIDOxgg82TeGA06MHAH/H07cjOzPWF0Wm0WW6pDw5kEAFAh5VqZ7oFDcKppZoabMADgpJx3HW4VJHUpKi+4bRRVFBwypdGw== X-Google-Smtp-Source: AGHT+IGRRRn8jhnGMQ1ZTMtih6hwurt4HX5RUL0kXBgDjGQQT7BcbACz2ZfF4JTxo6tiHngNOkGG X-Received: by 2002:a67:fd73:0:b0:476:df7b:8a16 with SMTP id h19-20020a67fd73000000b00476df7b8a16mr463180vsa.2.1711127837761; Fri, 22 Mar 2024 10:17:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711127837; cv=pass; d=google.com; s=arc-20160816; b=kJ4rqQSR3zYTT/fkJlIIFxLWq05f9uplP4O9VcYiXxEg0CpN6VrGHMYZUYMjbX+pJS y5ds/ou7QD0jxSxg9AqOyanKAbrguHQ1oBurR/+g9OI7QXvJyyn5WfYS9a7NP6S9Yvr/ OtfKZN9huGzl/SEZGE+wzrlgbV11i18v/X+SddR9LZ7hQBBr+Cos0dCrZZeTnFPcC5EX saKWuSwDh37rdXIHq4upQ65sz54yBqfPiiIa+74FETT04NvOPXH/l6dwXMBmAqWID8nj 9HTG5FbB8HBmqk46kxmIFz660QACTXAQYvhacPdSaM0PxQ+gnZep4RES0V7XT4W7aYf5 ss+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=2XgtdX5L83O8lONpj9+q9R68FKAPEzG1Evk2xJVlxNQ=; fh=WP8lnTeQceMriyg/M+XA0RcRGQr0Z3X+HM8Tl4hduNg=; b=sYWXnYap+CPZT5El+Et1u9riC1fbsF3ejleP2vy6drPe3p5jrhsSd9ymhz6EIP+R94 bz/OzeKPxGUsMedslZPrHN2JKg1P/k6/uOjbZ8UVowMwwZhWqBV8Wb+KEWEo8a4RFEQ0 blgYU6cSIxJV1LIH9HvvCpTyFs00EgwOQdKSHnSntKKbLHbI4oUEKc1+tvtp5VnbVlez TpLvAnKX18mX6NaRymf5gYjieJRkVA4S4iLhXUQSnvJ8aD24qsiggmN2HcPCW6j6c8Bd 0caxeqgONJyuh2XB1PEcO/sqiQXkh+Abpx3atLZsIx5sbI1WZ5w2JjOEK/1RbKduzf/P tLUQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="SHdW/Rxm"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-111862-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111862-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id dg25-20020a056102571900b004725ee4c810si23045vsb.625.2024.03.22.10.17.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Mar 2024 10:17:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-111862-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="SHdW/Rxm"; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-111862-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-111862-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 258271C22B09 for ; Fri, 22 Mar 2024 17:16:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A54C5FBAD; Fri, 22 Mar 2024 17:16:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="SHdW/Rxm" Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8AB4D5D909 for ; Fri, 22 Mar 2024 17:16:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711127801; cv=none; b=o3yInKjNzQa0Mf+eGSDrd9T5T/sS7BURrmegEDs3gMTzIeEkcjch0daS8/T74F7RA0gF5dLlAxY0jrsruOqswwx2RBJ26BNQXW31jd35P0hTVA4VwGGL3WW25tBGAZDnTu3PGGqykZZCUHsY8XAPKzQxGZvC5nkel5+UJyXgWE4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711127801; c=relaxed/simple; bh=2XgtdX5L83O8lONpj9+q9R68FKAPEzG1Evk2xJVlxNQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=LY5HSDDv3XJDYvSm3ekpw1JH6Y78lOjQDaqQmaccWA0jhNCk4VTvSKFDJTloYZ6bn8zZAIugMczEBe45dN9Tldfk1zv71xUlqDD6AwhmNVS3zHoz47gn0UdP75nyPNTPsqkj7N8ajwtE86SRTvvxZAe4q4JheVxvWKZGHjnTxWs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=SHdW/Rxm; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-1dddbe47ac1so22432735ad.1 for ; Fri, 22 Mar 2024 10:16:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711127799; x=1711732599; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=2XgtdX5L83O8lONpj9+q9R68FKAPEzG1Evk2xJVlxNQ=; b=SHdW/Rxm5925lwaw3dMiXq2MDAczpm7vBKy2/QhiWmEIHYz06oY5Q/+zNlvSpQgsNS lSm+VDZPyYmwdn+U3T0TsUG+BPGomZZADpAS60ZkYG8SvGCAvRXTExxFRF1oJUkQMjg+ VgCFwU1O2kEsJqP0wzO6Sh56vugeSj0JpblhSV4EuE2vLotzn37byK7JXDIBqSFgKHYO ssVs0YyKvldH1DkbFRVfGCngEwHlTsazq5oNESt7vsnRSYWma5INxQnC9GAPcuuxCtaP qQGMcBT5qbiPq532DoAcexyiyiDhcTv3+tZzb1TBacNwXXmqDLUu+bY7YW6PwB9PWWz/ xSkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711127799; x=1711732599; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2XgtdX5L83O8lONpj9+q9R68FKAPEzG1Evk2xJVlxNQ=; b=hfwINIAnp33CVzSPwkttqJErsZTjKLe+8RpMdgflbKp9XwWuDAhzmSjk5oOHAfrZAH xMbB//AvqEjN4R2dYh++IQSwoBJPDA5PZbXCR3EsuNKT0xXl+Dr21kzYNQ1dgVO+nerQ ILzCT/rA/6r0grHBT07FIahgqsERvOsOqvTWUSA3gZhuQpLyqjWNkklAoWejXAsCbnRf sjiT1TA6ynth0Gun9m1N7bzMgAHZC04z6kRLz5qBupwmNbrFR++OziK/N1+JW3TGPvsp F9UdX7L9ksFacrTQG+UYC+ua8h3AFNvANiNzbIpyUS8CoVYl/TYhDRnMkP45dNzjFyro kksg== X-Forwarded-Encrypted: i=1; AJvYcCVx74voTZijUmEgEZHxacQUTKQDNIz9aKs8lZzYvl8Du0MgsbjcUVvpqNQ35t+qIXeFTAaSWTdHOMYmBwnwoIN/g5l1naI7sakfWI1S X-Gm-Message-State: AOJu0Yw6Z183tNIsnIkaYv+ccV996tbGSJVUBXeEev4NM6jKAs+OH5zb gtiwMY0qgJNoruywaIU+t0ZHkBtOt3/u45nezmfL/ryTM51guZ3d2UMMbTR07pPkROtZRlhFemA qj/iUs4uC+bihwyW+IoXNK47xMWMDFfXmWk9x0Q== X-Received: by 2002:a17:903:32ca:b0:1e0:93b1:3a31 with SMTP id i10-20020a17090332ca00b001e093b13a31mr3001188plr.18.1711127798785; Fri, 22 Mar 2024 10:16:38 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20220825122726.20819-1-vincent.guittot@linaro.org> <20220825122726.20819-2-vincent.guittot@linaro.org> In-Reply-To: From: Vincent Guittot Date: Fri, 22 Mar 2024 18:16:27 +0100 Message-ID: Subject: Re: [PATCH 1/4] sched/fair: make sure to try to detach at least one movable task To: Josh Don Cc: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, linux-kernel@vger.kernel.org, zhangqiao22@huawei.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, 21 Mar 2024 at 21:25, Josh Don wrote: > > On Wed, Mar 20, 2024 at 9:58=E2=80=AFAM Vincent Guittot > wrote: > > > > Hi Josh, > > > > Sorry for the late reply. > > No worries, responses to your comments inline below. > > > > We had a user recently trigger a hard lockup which we believe is due > > > to this patch. The user in question had O(10k) threads affinitized to > > > a cpu; seems like the process had an out of control thread spawning > > > issue, and was in the middle of getting killed. However, that was > > > being slowed down due to the fact that load balance was iterating all > > > > Does it mean that it was progressing but not as fast as you would like > > It was a hard lockup, so it's more than just "not fast enough". > Indeed it was progressing, but not at a rate sufficient to avoid > lockup. > > > > these threads and bouncing the rq lock (and making no progress due to > > > ALL_PINNED). Before this patch, load balance would quit after hitting > > > loop_max. > > > > > > Even ignoring that specific instance, it seems pretty easy for this > > > patch to cause a softlockup due to a buggy or malicious process. > > > > The fact that the rq is released regularly should prevent a > > softlockup. > > That doesn't prevent a softlockup; kernel is stuck looping over a long > list of tasks for too long, regardless of whether it is releasing and > re-acquiring the rq locks. > > Note also that load balance can come from softirq in a context where > we have IRQ disabled, which can lead to hard lockup as well. fair enough > > > And we could even fasten can_migrate() which does a lot of > > useless stuff for task affined to 1 cpu. > > That seems like a useful optimization, but not really relevant? It > doesn't matter how small we make the constant factor, we still have an > O(n) operation in kernel mode here. > > > > For the tradeoff you were trying to make in this patch (spend more > > > time searching in the hopes that there's something migratable further > > > in the list), perhaps it would be better to adjust > > > sysctl.sched_nr_migrate instead of baking this into the kernel? > > > > That could be a solution but this increases the iterations for all > > cases including those which are more time consuming to sort out and > > the number of tasks that you will migrate in one lb. The latter is the > > one which consumes time > > Is is really that bad? loop_max will be unchanged for most cases since > it gets min'd with nr_running anyway. And, even if loop_max ends up > larger in some other instances, we still terminate the iteration after > fixing up env->imbalance (granted, we'll migrate more tasks to achieve > a better balance with a larger loop_max, which I think is your point). Yes, my point is that load of a task can be quite small, especially with cgroups, so we can end up detaching/attaching a very large number of tasks which is far more time consuming that checking if we can migrate it or not > > > Another idea then: what about separating the number of tasks we can > move from the number of tasks we can search? You effectively want to > keep the number of tasks that can be migrated small (nr_migrate), but > be able to search deeper in the list for things to pull (a larger > search_depth). That could be a solution indeed > > - Josh