From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-118.freemail.mail.aliyun.com (out30-118.freemail.mail.aliyun.com [115.124.30.118]) (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 5162817D2 for ; Tue, 31 Dec 2024 06:01:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.118 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735624899; cv=none; b=pRLDUrrMmXfUezG2B11Is/8yLH94xZQMQFzbKCpYhDYgg+ylMnNozfDaUega9peJ8dv0EB43H3CFq9501lM//3/zYDoitZXW3T/R+rgDvIoajJA2AFptfjrrKd20koL8nV4NXBLR7Q9ZDuNOYI4N/yp9iPmn9ZjHdLFbWJUyPHw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735624899; c=relaxed/simple; bh=kzuDOVaReNjLlVMnVvscAwiVLD2nfhRUsclgJs9YXkc=; h=Message-ID:Date:MIME-Version:Subject:From:To:Cc:References: In-Reply-To:Content-Type; b=Fg5Onl0UVOMPlYGRHuQdhc3VcD3jdHjbfPw1F/ApPE1W4M5xgeyulwQbkA56kd7T2D+gm0xohiTZ6RfJ1nKOc72PxXL87Bm4jeNpfLH3/TNjl14RUh4Rn0rMiy9IdBfO7BLa2o86JaECuq86d2GPIfEAu/9D9KHM6Z5LXuSH1yY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=isD51tmG; arc=none smtp.client-ip=115.124.30.118 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="isD51tmG" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1735624894; h=Message-ID:Date:MIME-Version:Subject:From:To:Content-Type; bh=ce/VWriJELKXzfykNKQZAx+3vK/Gos4951pOXLmN1Ag=; b=isD51tmGw1nKMIjwrRJ9kpOt/FZ4foKYkzVfOh7nhBB9TJTIBq4VFTeLVFz+/eo76vIHTjq6aAXVmTV8KOdEeX1EhFkFGLPnu6kWDr09HQFWVMF5KleQRbzdYRLTnvt0o6ZVl1UjbHO+yYQKir5a0cKQlwgsXvInXtwaajxXvZE= Received: from 30.74.129.201(mailfrom:dtcccc@linux.alibaba.com fp:SMTPD_---0WMcuW5d_1735624564 cluster:ay36) by smtp.aliyun-inc.com; Tue, 31 Dec 2024 13:56:16 +0800 Message-ID: Date: Tue, 31 Dec 2024 13:56:03 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] sched: Fix race between yield_to() and try_to_wake_up() From: Tianchen Ding To: linux-kernel@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Marcelo Tosatti , Mike Galbraith , Rik van Riel References: <20241231055020.6521-1-dtcccc@linux.alibaba.com> Content-Language: en-US In-Reply-To: <20241231055020.6521-1-dtcccc@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024/12/31 13:50, Tianchen Ding wrote: > We met a SCHED_WARN in set_next_buddy(): > __warn_printk > set_next_buddy > yield_to_task_fair > yield_to > kvm_vcpu_yield_to [kvm] > ... > > After a short dig, we found the rq_lock held by yield_to() may not > be exactly the rq that the target task belongs to. There is a race > window against try_to_wake_up(). > > CPU0 target_task > > blocking on CPU1 > lock rq0 & rq1 > double check task_rq == p_rq, ok > woken to CPU2 (lock task_pi & rq2) > task_rq = rq2 > yield_to_task_fair (w/o lock rq2) > > In this race window, yield_to() is operating the task w/o the currect Sorry... a typo for "correct"