Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp145171lqt; Mon, 18 Mar 2024 04:18:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWnoXSidEMhhvLYott8FCB/hVDPN6M35ph6ud8RnHMQZkfeNsbBMAyFQ1NnQe6kd2YS51Y5QMi2+D2ZVOgt47YCl6Ev4Q/WGiteu+KpFw== X-Google-Smtp-Source: AGHT+IHKQuoVZMZLoZeZ0GZoYjYUVYzawJvAgBbCi0pBlIPc7qBO/KVUwXZaT83XtU2DdCd0g80k X-Received: by 2002:a17:907:b9cd:b0:a46:ccda:c169 with SMTP id xa13-20020a170907b9cd00b00a46ccdac169mr737248ejc.72.1710760739620; Mon, 18 Mar 2024 04:18:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710760739; cv=pass; d=google.com; s=arc-20160816; b=abzCjexDLaFnJ/VUkfN2R+IeFVirQv8Y9plNNRwnSj0Lp1by8A7vV0WjwEMOFfz3jh DFEcdNDT4zJwmFPtbPfPQmTVrniVOcK8enFtxhELLZeRAi3Sn1lsT8mNq733rWBZ94N7 j4DWMs6BMoxTXzoTLUu0TOkKCNKZYMKhaHvJ2RwqBQvlhv+/Zxd+SlHSjm6wWjZ2M6/Y 51hk7Rw9bj/t2Rdf2SJIrKbgARgRGhDDQRJrF1GuF4vNgS2hm5sdWIaEg82C0k6MwsKW 3tRgLEpUzdEaIF3beNWiGuP5dWUscCPXdj5/ir1WxU6u1dWhnbarmP7w/G7928OnTqSd DsZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=8Xrq8vJ1NagCe+cTWlPAdrkNTdkW7Dtp8mrb26EB1sQ=; fh=SiJVp6Zkwu8+9NOtjmxEF/4tnRO0oDRGiNEWv/PcXnI=; b=q+ke9Lt8WBtwcGfVuKvc175mE8RU7dvkPlHUho62Lh4jFtVSJgp5qaiJ5/8EZhjPeK kE8OjCg022Zkl9lSOSIRuqitr3PtSaO2BEFWMd+3d0XovcWYO8ttZNZOGuykwiL075U2 6DRUq2LegxR0Pbv3WNQNwY50y8TvuEz2LFW+Xkgy4wqfjTLEibjNuXAqgqzYwcBrV6BW jAPfUzMRGSphZ0JUwR+WXR8krbgNsbXxsTq1lUSzinqk70ljWlPqx0PnB7LmVzgt01Zc 3NOT0mptfyVXM5jpskIcYItUMOqtPL+6Pe3TZ+mZq/4mwYFOwicZFPP5FrSaLNbQGx/l NMpQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Y9JCD/S6"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-106050-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106050-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id nc14-20020a1709071c0e00b00a46ab36400fsi2002598ejc.817.2024.03.18.04.18.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 04:18:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106050-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Y9JCD/S6"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-106050-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106050-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2095E1F2309F for ; Mon, 18 Mar 2024 11:18:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B0CD364B4; Mon, 18 Mar 2024 11:18:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Y9JCD/S6" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A423D3611E for ; Mon, 18 Mar 2024 11:18:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710760692; cv=none; b=iHH0PoIBB2fLXWw33yvlOAqHpaQ96r1OIKYAmWhFb1OyucKMs8MjrGV6zF3s+HLTmsl637qKEST2Z2WCn+6CxTJxpxBgBOxTg9cVRkBFNNO1RImZqhP30uS+dcH2vhW3sZRJxcUFmwiWKM5qq+a5xC5r1VskbmIa/RibdVBOg9I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710760692; c=relaxed/simple; bh=O8orsh4fpL1MSr02xvuqLOzLtF3YhhKLmLgVXGjAEP4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=jtSM7nOIWloUW08sSmQ/R+7KrLimB/782PNYam7D8gPQZCnuwldCHabHuvB5b0ys32CHVu86HNEZGrjeGQ71TGAHEe2fLl0VA8H5W2v/T9dzPP2t7C/xUIio/3vt/2lLFOofwVg1eSlrbgANmJqkp1BTVzBbaxQXGTK90c93ek0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Y9JCD/S6; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710760689; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=8Xrq8vJ1NagCe+cTWlPAdrkNTdkW7Dtp8mrb26EB1sQ=; b=Y9JCD/S6pUU2VNUvtaEoumt2fdzWniUYhyDnuHMRFzxwyRpSiZTh6ZhSqlO9n3RmV3K05v lHAYNxYPXcQVeOELJFKTRBQA9N//QPtBKfzA138IobnMMYbsRvDWc/hOnNg4ZnuZEyu56L zZa+g2/uwmxSIzvtXgc9VJfXQKTxKf4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-107-AXyhhxoHONWn_NAucC7XSQ-1; Mon, 18 Mar 2024 07:18:04 -0400 X-MC-Unique: AXyhhxoHONWn_NAucC7XSQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BFBA1101A5B3; Mon, 18 Mar 2024 11:18:03 +0000 (UTC) Received: from metal.redhat.com (unknown [10.45.225.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8C333492BD0; Mon, 18 Mar 2024 11:18:00 +0000 (UTC) From: Daniel Vacek To: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider Cc: Daniel Vacek , stable@vger.kernel.org, Bill Peters , Ingo Molnar , linux-kernel@vger.kernel.org Subject: [PATCH] sched/core: fix affine_move_task failure case Date: Mon, 18 Mar 2024 12:17:48 +0100 Message-ID: <20240318111750.3097906-1-neelx@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 Bill Peters reported CPU hangs while offlining/onlining CPUs on s390. Analyzing the vmcore data shows `stop_one_cpu_nowait()` in `affine_move_task()` can fail when racing with off-/on-lining resulting in a deadlock waiting for the pending migration stop work completion which is never done. Fix this by correctly handling such a condition. Fixes: 9e81889c7648 ("sched: Fix affine_move_task() self-concurrency") Cc: stable@vger.kernel.org Reported-by: Bill Peters Tested-by: Bill Peters Signed-off-by: Daniel Vacek --- kernel/sched/core.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 9116bcc903467..d0ff5c611a1c8 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3069,8 +3069,17 @@ static int affine_move_task(struct rq *rq, struct task_struct *p, struct rq_flag preempt_disable(); task_rq_unlock(rq, p, rf); if (!stop_pending) { - stop_one_cpu_nowait(cpu_of(rq), migration_cpu_stop, - &pending->arg, &pending->stop_work); + stop_pending = + stop_one_cpu_nowait(cpu_of(rq), migration_cpu_stop, + &pending->arg, &pending->stop_work); + + if (!stop_pending) { + rq = task_rq_lock(p, rf); + pending->stop_pending = false; + p->migration_pending = NULL; + task_rq_unlock(rq, p, rf); + complete_all(&pending->done); + } } preempt_enable(); -- 2.43.0