Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp719372lqp; Thu, 21 Mar 2024 13:26:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXk7Kjqhf4NxIoFcNu9QgSPNeOl1kJQ4ly6JfzEIRLUjfTyxNC/tqFqgytLyeHpe24XLqK/V8D9Bkfwy+5o3A+KJeKT1GgznGAFLfJaAw== X-Google-Smtp-Source: AGHT+IESm3NaaXx+Ne/hD08PujXWswhQQWP3nfcMJiBegi6CWU7C9HYA4PxhPxqiDUg/tw2AWiym X-Received: by 2002:a05:620a:37a7:b0:789:f174:c3bd with SMTP id pi39-20020a05620a37a700b00789f174c3bdmr256794qkn.19.1711052760687; Thu, 21 Mar 2024 13:26:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711052760; cv=pass; d=google.com; s=arc-20160816; b=Q7UkX+Gz5MmykKuk4rQrPHGj2FnH5XrfETsOT/EWsA8AHmAs+NZ8jEf9YmXwdhcBVf 8IlgznbKlWAMXd2k4e8NuBUDuBdIo+qwifhWsG/6HWBb5sIQh36TmcNyqQojs0V0J8sH BEc5fLfC6n3ksJm4+Yq6rmfbTwpVgS7izSRfGgn4dmEX0ZpCMwoESawZ4e35OOBM2L2i g23LUAYrW6Zf80rkdbwvFpFiShZClc4MoHpomk0x4bxvSK+pjVmeE0w342nC9LYmVvOt 4MefXwY28XbJX+n7wyfXz+SCeP7gR9jhAfU4XnVix94+hfAG5a/iZiqBgOlx2A5awpCe WFOQ== 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=KFPqyrctUaYq3cli0WFxDcsfh2suA7GJpBgvoQCG1WA=; fh=N7Jc2gI3T2XFYLXlyOh4dkq/m8oDPEmO72kuCi8iRos=; b=e1sfeVMqShH9VZfad94SGvQ1cZCka7pcWmF2uPAh8cGtNQMCMkCOmzl6MI28Xj9ylG 7oYT1ZFiGAfoMxk67eIiOLQm565Tmoc95rznIHxvvilvPtczHS7BsD5TOE/WXzgbgVb1 SoCl09exAmFyRH8XOsoanPIXrs42yN5RV1oXDEJGc9quvPgr6nNTF+UfH7IvcclVaLJK NUNXyLOOpUSCY7KTAPK2Wj22mjPL61K5+5AnA6KgMS5QSjFBeEoK8qGYIN8dFsPpQen1 7MQn6yyOOxuXQWxvjvkC2hNxmNGQYI7s6BpxKOVk+01ND5Q8BQWWJpNrynchOtkDRdS7 oMlQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=Wb5frFT7; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-110638-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110638-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h15-20020a05620a10af00b0078a363921f4si478699qkk.650.2024.03.21.13.26.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Mar 2024 13:26:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-110638-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=@google.com header.s=20230601 header.b=Wb5frFT7; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-110638-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-110638-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 5D2E51C21C5F for ; Thu, 21 Mar 2024 20:26:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BB05134CC8; Thu, 21 Mar 2024 20:25:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Wb5frFT7" Received: from mail-ed1-f42.google.com (mail-ed1-f42.google.com [209.85.208.42]) (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 DE6ED79F0 for ; Thu, 21 Mar 2024 20:25:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711052754; cv=none; b=lH1XcmBc2l/+1cljFR9Nn4kDTujC3DX6wDs/wRZ7Bn0W2ckGQ/ptmYdJdEbr6I5qw1S5Ftic2KexEgf9295QAdul+3U8/j8ZpwBxy0Y6/mcyc/t8uiYUsDRPCAw4YkEbXiL4OxxFt7mDY3RNAvGnf9n7oSSycjlyGMEpxGDTDy8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711052754; c=relaxed/simple; bh=KFPqyrctUaYq3cli0WFxDcsfh2suA7GJpBgvoQCG1WA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=mF2IVp6nHhDSxj8mD0nm76x8hahi/RYXyIOwTXVjJboWqQPt2E5xQ7nlk0rZj0pqoiqJo36+rJvkS/WBW8boJ4IoWBOmm+cyZ2AFD2/XXTL2szRxoNXGSbFAZJPc+LmN0XJkLv9HBHPckoecu7IJhBp1AMYszLR5jp4BwnxXZXw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Wb5frFT7; arc=none smtp.client-ip=209.85.208.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-56b9dac4e6cso450a12.1 for ; Thu, 21 Mar 2024 13:25:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711052751; x=1711657551; 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=KFPqyrctUaYq3cli0WFxDcsfh2suA7GJpBgvoQCG1WA=; b=Wb5frFT7aidgDpbBdzBaFW025n/Ekv+RHP+QqWDbro7HCTapHWJRPkiKs7w54GsnlQ B4TNk0flfGbQ3U3njwkL2CYMZQXbJCio5GeoTJMojWmV/LDNbG0UoorSmYUQew3H4vJX OUHgOg5W3P021ahqWwmupfy1ycUrjH0oatr5UrzHgP55hNF6kdGjyJg7xAh5i+CYauH3 SNvvAxY2f9Vi5vWTnOiUbZUPwLGDSvO4/IEzWcLEftCCAhnRkAgtcQM4ezflkJ+AXgId dAMeeiDNQ9B23xCD0fnngsxHam83Ug8fQObm2rRX//aK4JjTM3O8if4ffFIfGkdiRv2o OiPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711052751; x=1711657551; 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=KFPqyrctUaYq3cli0WFxDcsfh2suA7GJpBgvoQCG1WA=; b=wSSH0MU46SXJXsh74HjhKnWVLZoUhEAzFzxBV6ORMD2ByB3CujYalg/VDmswgZm6kS PAffxnlhlmhN+ODdAPMh2mLpVFFuvrrtv8GVQnzRVrsD3hxQPbJClP/jOEnvDVRmSq9H rg7/59HNpjhT9QPH8QdOp2TCz7Ts8oaHaLDXQMzhWfCFKgP5JWzNfILQOfguFWLDWVBf JXzBokoDLPhyMAT1aeF4TUXVWXDSNapIfc2qEvCNN4o7Uo7aUAm7xAR4i9m1gd9tStfi BcksHuKotFmVz2bDa+kSFgxxfdReU5FwrrK/7rACskUwZhcVEEoX+i4iAguxz5dwHVux NVZg== X-Forwarded-Encrypted: i=1; AJvYcCXoTTbDRIrkvmb9vPZ8d7jmZQ9n9h22NdlpxlVmjQaUkO1GfDqhMll7FKG0JicBqXamCYqeIzrtbW/t9eWAETTy0c9IDIm7Y42gCu29 X-Gm-Message-State: AOJu0YyBvZBu1Zf8FspdsihSYJt8cu8l9hY9R+YUdDcTzmXpFCKNfAin oqtcnCaAGfCWixpIPAtf/VSWWsp4r+5tJe4oNFnWvwdwjuJRmyxGdkHcGBhYMxlCzkw/fkYDa3D o113WlLvvRkvK4epGAf7Bj+gxdbSkKk8IURUA X-Received: by 2002:aa7:d156:0:b0:56b:a060:1e4 with SMTP id r22-20020aa7d156000000b0056ba06001e4mr278342edo.2.1711052750857; Thu, 21 Mar 2024 13:25:50 -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: Josh Don Date: Thu, 21 Mar 2024 13:25:38 -0700 Message-ID: Subject: Re: [PATCH 1/4] sched/fair: make sure to try to detach at least one movable task To: Vincent Guittot 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 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. > 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). 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). - Josh