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 mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31D65C433EF for ; Sun, 17 Jul 2022 09:28:43 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 8991B4C81B; Sun, 17 Jul 2022 05:28:43 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@linux.dev Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XILMjVftFFJM; Sun, 17 Jul 2022 05:28:42 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 4DBAD4C291; Sun, 17 Jul 2022 05:28:42 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id BC9A54C8D9 for ; Sat, 16 Jul 2022 17:48:18 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mMm4LlDZlJA5 for ; Sat, 16 Jul 2022 17:48:17 -0400 (EDT) Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id 8837E4C8D8 for ; Sat, 16 Jul 2022 17:48:17 -0400 (EDT) MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1658008095; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x3HXgQUrco41LDbc708fhSxzFK309rLRf0po+Yszzrw=; b=eCdBgF63tI6bMObcpQ2Y+ue1cynT4Jr8YlUT8CmT88+KL0ZW5coTxvgDrWRKX0eWg+R9XG pAOeZUmflMafSfx6A4PQQXlBtoyV3SsnNpBSBlNL+gWLnU3/za90g0hILCXV5Yc4rzKB6w 8Z2sLk2hjVwpKt6sYGVst9+JhM6176I= Date: Sat, 16 Jul 2022 21:48:13 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: oliver.upton@linux.dev Message-ID: <385aa28ad559874da8429c40a68570df@linux.dev> Subject: Re: [PATCH v2] KVM: selftests: Fix target thread to be migrated in rseq_test To: "Gavin Shan" , kvmarm@lists.cs.columbia.edu In-Reply-To: <20220716144537.3436743-1-gshan@redhat.com> References: <20220716144537.3436743-1-gshan@redhat.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Mailman-Approved-At: Sun, 17 Jul 2022 05:28:40 -0400 Cc: shan.gavin@gmail.com, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, maz@kernel.org, pbonzini@redhat.com, shuah@kernel.org X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu Hi Gavin, Thanks for cleaning this up. July 16, 2022 7:45 AM, "Gavin Shan" wrote: > In rseq_test, there are two threads, which are thread group leader > and migration worker. The migration worker relies on sched_setaffinity() > to force migration on the thread group leader. It may be clearer to describe it as a vCPU thread and a migration worker thread. The meat of this test is to catch a regression in KVM. > Unfortunately, we have s/we have/the test has the/ > wrong parameter (0) passed to sched_getaffinity(). wrong PID > It's actually > forcing migration on the migration worker instead of the thread group > leader. What's missing is _why_ the migration worker is getting moved around by the call. Perhaps instead it is better to state what a PID of 0 implies, for those of us who haven't read their manpages in a while ;-) > It also means migration can happen on the thread group leader > at any time, which eventually leads to failure as the following logs > show. > > host# uname -r > 5.19.0-rc6-gavin+ > host# # cat /proc/cpuinfo | grep processor | tail -n 1 > processor : 223 > host# pwd > /home/gavin/sandbox/linux.main/tools/testing/selftests/kvm > host# for i in `seq 1 100`; \ > do echo "--------> $i"; ./rseq_test; done > --------> 1 > --------> 2 > --------> 3 > --------> 4 > --------> 5 > --------> 6 > ==== Test Assertion Failure ==== > rseq_test.c:265: rseq_cpu == cpu > pid=3925 tid=3925 errno=4 - Interrupted system call > 1 0x0000000000401963: main at rseq_test.c:265 (discriminator 2) > 2 0x0000ffffb044affb: ?? ??:0 > 3 0x0000ffffb044b0c7: ?? ??:0 > 4 0x0000000000401a6f: _start at ??:? > rseq CPU = 4, sched CPU = 27 > > This fixes the issue by passing correct parameter, tid of the group > thread leader, to sched_setaffinity(). Kernel commit messages should have an imperative tone: Fix the issue by ... > Fixes: 61e52f1630f5 ("KVM: selftests: Add a test for KVM_RUN+rseq to detect task migration bugs") > Signed-off-by: Gavin Shan With the comments on the commit message addressed: Reviewed-by: Oliver Upton _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 957B2C43334 for ; Sat, 16 Jul 2022 21:48:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232057AbiGPVsU (ORCPT ); Sat, 16 Jul 2022 17:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229941AbiGPVsT (ORCPT ); Sat, 16 Jul 2022 17:48:19 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 851AD18E13; Sat, 16 Jul 2022 14:48:18 -0700 (PDT) MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1658008095; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x3HXgQUrco41LDbc708fhSxzFK309rLRf0po+Yszzrw=; b=eCdBgF63tI6bMObcpQ2Y+ue1cynT4Jr8YlUT8CmT88+KL0ZW5coTxvgDrWRKX0eWg+R9XG pAOeZUmflMafSfx6A4PQQXlBtoyV3SsnNpBSBlNL+gWLnU3/za90g0hILCXV5Yc4rzKB6w 8Z2sLk2hjVwpKt6sYGVst9+JhM6176I= Date: Sat, 16 Jul 2022 21:48:13 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: oliver.upton@linux.dev Message-ID: <385aa28ad559874da8429c40a68570df@linux.dev> Subject: Re: [PATCH v2] KVM: selftests: Fix target thread to be migrated in rseq_test To: "Gavin Shan" , kvmarm@lists.cs.columbia.edu Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, seanjc@google.com, pbonzini@redhat.com, maz@kernel.org, shuah@kernel.org, shan.gavin@gmail.com In-Reply-To: <20220716144537.3436743-1-gshan@redhat.com> References: <20220716144537.3436743-1-gshan@redhat.com> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Hi Gavin,=0A=0AThanks for cleaning this up.=0A=0AJuly 16, 2022 7:45 AM, "= Gavin Shan" wrote:=0A> In rseq_test, there are two thr= eads, which are thread group leader=0A> and migration worker. The migrati= on worker relies on sched_setaffinity()=0A> to force migration on the thr= ead group leader.=0A=0AIt may be clearer to describe it as a vCPU thread = and a migration worker=0Athread. The meat of this test is to catch a regr= ession in KVM.=0A=0A> Unfortunately, we have=0A=0As/we have/the test has = the/=0A=0A> wrong parameter (0) passed to sched_getaffinity().=0A=0Awrong= PID=0A=0A> It's actually=0A> forcing migration on the migration worker i= nstead of the thread group=0A> leader.=0A=0AWhat's missing is _why_ the m= igration worker is getting moved around by=0Athe call. Perhaps instead it= is better to state what a PID of 0 implies,=0Afor those of us who haven'= t read their manpages in a while ;-)=0A=0A> It also means migration can h= appen on the thread group leader=0A> at any time, which eventually leads = to failure as the following logs=0A> show.=0A> =0A> host# uname -r=0A> 5.= 19.0-rc6-gavin+=0A> host# # cat /proc/cpuinfo | grep processor | tail -n = 1=0A> processor : 223=0A> host# pwd=0A> /home/gavin/sandbox/linux.main/to= ols/testing/selftests/kvm=0A> host# for i in `seq 1 100`; \=0A> do echo "= --------> $i"; ./rseq_test; done=0A> --------> 1=0A> --------> 2=0A> ----= ----> 3=0A> --------> 4=0A> --------> 5=0A> --------> 6=0A> =3D=3D=3D=3D = Test Assertion Failure =3D=3D=3D=3D=0A> rseq_test.c:265: rseq_cpu =3D=3D = cpu=0A> pid=3D3925 tid=3D3925 errno=3D4 - Interrupted system call=0A> 1 0= x0000000000401963: main at rseq_test.c:265 (discriminator 2)=0A> 2 0x0000= ffffb044affb: ?? ??:0=0A> 3 0x0000ffffb044b0c7: ?? ??:0=0A> 4 0x000000000= 0401a6f: _start at ??:?=0A> rseq CPU =3D 4, sched CPU =3D 27=0A> =0A> Thi= s fixes the issue by passing correct parameter, tid of the group=0A> thre= ad leader, to sched_setaffinity().=0A=0AKernel commit messages should hav= e an imperative tone:=0A=0AFix the issue by ...=0A=0A> Fixes: 61e52f1630f= 5 ("KVM: selftests: Add a test for KVM_RUN+rseq to detect task migration = bugs")=0A> Signed-off-by: Gavin Shan =0A=0AWith the com= ments on the commit message addressed:=0A=0AReviewed-by: Oliver Upton