Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1483772pxk; Fri, 2 Oct 2020 10:35:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyX/eNIJaP7NOGkdCcNmN44rV7NFuiL16nn+mjlUVjTT0iUdDMUH+M4G5ngFvHsEg/XqODL X-Received: by 2002:a05:6402:b64:: with SMTP id cb4mr3577437edb.25.1601660128294; Fri, 02 Oct 2020 10:35:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601660128; cv=none; d=google.com; s=arc-20160816; b=aV/W8uKEmAX48A2yHnWORqAwtVf59Kv8eG8LUtcUGMJADVhQh3gNY9TXxoyX9VAKfT JBHwqs1V0SE/cqyRp1psBw64xXNhktszhchKls7m6sWTlHNgS4oWXttTPXpzzQM1Cq5p s0OyC8P8VUZDDivaWq+/XqB7xW3/zeC+KPq2L55/Erm+5+zYxNUlbF7ASzW4376MHgRf EBiN2cnqnLhHw/nY5RiflagcP4Mg044YrbQVXqbs/TjWvrfpiFxWcv42E/L4ZbKUsvfR poSEsoJIJP62Rj5cEKF4UokOi2iQnNlz8NzdU46EDiXrMxSbItb8izQOyxEdsFuVC3FP +1DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rUB+RLk3PpShfXBqDpZYZe36j+5/9E7JczJN7NQ9uno=; b=fUblqSpz/grd99uaQcKqVG5pB60WZmj9P1TPYaitdTEl88FpvA65Kvu+I4aH9CJCdD Ou9z9HAOEBvMe65wabODFGdX0t71LLUPdFMnA0qqPmMzxJM7a4Ods4XziFEQ3ouU7LcI svcDnnu9x4RhyAwZDixdiTVb2IxW65V9qCce/eqIWXCx7Jlt6BADx09MrOpeq58ttF59 cYgI1FMK54aLfHfWYlUNd3uPpXWK5i+V1sYZqEGxYA2pOu6pVBs5HHDq5yj9LuqqO8r9 fp19eaQQpe36Dq76ZaGzbIanrwaBOTrLaXEh/OQOeZJZWiKwYaK3fWGLudJwAkXSNGr0 cR7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YjsyE36h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gj23si1738589ejb.419.2020.10.02.10.35.05; Fri, 02 Oct 2020 10:35:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YjsyE36h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388184AbgJBRbr (ORCPT + 99 others); Fri, 2 Oct 2020 13:31:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387908AbgJBRbr (ORCPT ); Fri, 2 Oct 2020 13:31:47 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69F34C0613E3 for ; Fri, 2 Oct 2020 10:31:46 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id 60so2127375otw.3 for ; Fri, 02 Oct 2020 10:31:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rUB+RLk3PpShfXBqDpZYZe36j+5/9E7JczJN7NQ9uno=; b=YjsyE36hS3ag8aak5brR0ERZIBQK/xagWisuHtNr5mrtPspdbyxWqxgv6WobzeGsU3 AN3KuXZMRhgHAtH70eUnMpJf8GNtBOdZnIyDz3MRRG1x8RCukJ3i07Sj7f52I9Oygyil x3rRP66aChwnRvohcRykHqp1zRxx6M9OMEFHUvYUptScpGMhd/e36LWPWii/nQJcLg6n 7bIIVzlSGk8Q//9vDoyO4NrkMiiF2dN4afHAvH5KdkKtNAsmG+0ooxG9L1BjMXPEXV75 vpfV9GrLSdEoMKNEH4ILodCA0i7WYtljNw5hZ+brKZ2QQCtEWXmDJuZSWNeCdFyfUCFw NXKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rUB+RLk3PpShfXBqDpZYZe36j+5/9E7JczJN7NQ9uno=; b=NBAj5H8XVIynQ65cE9iXB0uTZ3RSeQU0sZkCSYBY+6EkKyu1Tr3GrBb+l9kjmzCgw+ OKj/ZedHC8z1EJdpmJ/h6Zn4iZSDad4Yio96AVZq/2bXuiJUDKr6S1aL2p0+tLClod53 dKKVFxEFGP63pxl0yntPXoXYFoD5VjilyofYxTejk3rXULcH4VcflcNdL2CJCnP/tvOi tf0MOes63JbYwQqYYxFb7bIMgQ/MkOSHt2T268ePg9IJX/ceYYsHJC/OMqNGjEr0S4JP /nT6IRadx29w0Nq6E3Xc6zunDEjwy4pjFSfoAKFvA2KUR5NBANF5h0XXm3vGDPsnNkoC q45A== X-Gm-Message-State: AOAM5320IJlsJQl14LFcGtNf1aE8jBCiNgTAQ5pPtdIubv6/x/bYp4Sh PyrRii6d2hl1BbzNmZk3SQ/OseGXZDz/2vgfh5hxOg== X-Received: by 2002:a9d:4b99:: with SMTP id k25mr2608245otf.281.1601659905629; Fri, 02 Oct 2020 10:31:45 -0700 (PDT) MIME-Version: 1.0 References: <20200924143317.getruzwu423g3o3e@wittgenstein> <20200924162126.mbthwz32w7rba7oe@wittgenstein> In-Reply-To: <20200924162126.mbthwz32w7rba7oe@wittgenstein> From: Naresh Kamboju Date: Fri, 2 Oct 2020 23:01:34 +0530 Message-ID: Subject: Re: selftests: pidfd: pidfd_wait hangs on linux next kernel on all devices To: Christian Brauner Cc: "open list:KERNEL SELFTEST FRAMEWORK" , linux-api@vger.kernel.org, open list , Christian Brauner , Kees Cook , "Peter Zijlstra (Intel)" , Ingo Molnar , Thomas Gleixner , Oleg Nesterov , "Eric W. Biederman" , Sargun Dhillon , Aleksa Sarai , Josh Triplett , Jens Axboe , Shuah Khan , lkft-triage@lists.linaro.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 24 Sep 2020 at 21:51, Christian Brauner wrote: > > On Thu, Sep 24, 2020 at 04:33:17PM +0200, Christian Brauner wrote: > > On Wed, Sep 23, 2020 at 07:52:05PM +0530, Naresh Kamboju wrote: > > > selftests: pidfd: pidfd_wait hangs on linux next kernel on x86_64, > > > i386 and arm64 Juno-r2 > > > These devices are using NFS mounted rootfs. > > > I have tested pidfd testcases independently and all test PASS. > > > > > > The Hang or exit from test run noticed when run by run_kselftest.sh > > > > > > pidfd_wait.c:208:wait_nonblock:Expected sys_waitid(P_PIDFD, pidfd, > > > &info, WSTOPPED, NULL) (-1) == 0 (0) > > > wait_nonblock: Test terminated by assertion > > > > > > metadata: > > > git branch: master > > > git repo: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git > > > git commit: e64997027d5f171148687e58b78c8b3c869a6158 > > > git describe: next-20200922 > > > make_kernelversion: 5.9.0-rc6 > > > kernel-config: > > > http://snapshots.linaro.org/openembedded/lkft/lkft/sumo/intel-core2-32/lkft/linux-next/865/config > > > > > > Reported-by: Naresh Kamboju > > > > Thanks for reproting this. I'm taking a look now! > > Ok, this is a simple race in the selftests, that I overlooked and which > is more likely to hit when there's a lot of processes running on the > system. Basically the child process hasn't SIGSTOPed itself yet but the > parent is already calling waitid() on a O_NONBLOCK pidfd. Since it > doesn't find a WSTOPPED process it returns -EAGAIN correctly. > > The fix for this is to move the line where we're removing the O_NONBLOCK > property from the fd before the waitid() WSTOPPED call so we hang until > the child becomes stopped. > > So I believe the fix is: I have tested this patch and the pidfd_wait test did not hang this time. Tested-by: Naresh Kamboju test log link https://lkft.validation.linaro.org/scheduler/job/1813223 > > diff --git a/tools/testing/selftests/pidfd/pidfd_wait.c b/tools/testing/selftests/pidfd/pidfd_wait.c > index 4063d6f31fa4..be2943f072f6 100644 > --- a/tools/testing/selftests/pidfd/pidfd_wait.c > +++ b/tools/testing/selftests/pidfd/pidfd_wait.c > @@ -205,6 +205,8 @@ TEST(wait_nonblock) > ret = sys_waitid(P_PIDFD, pidfd, &info, WEXITED | WNOHANG, NULL); > ASSERT_EQ(ret, 0); > > + ASSERT_EQ(fcntl(pidfd, F_SETFL, (flags & ~O_NONBLOCK)), 0); > + > ASSERT_EQ(sys_waitid(P_PIDFD, pidfd, &info, WSTOPPED, NULL), 0); > ASSERT_EQ(info.si_signo, SIGCHLD); > ASSERT_EQ(info.si_code, CLD_STOPPED); > @@ -212,8 +214,6 @@ TEST(wait_nonblock) > > ASSERT_EQ(sys_pidfd_send_signal(pidfd, SIGCONT, NULL, 0), 0); > > - ASSERT_EQ(fcntl(pidfd, F_SETFL, (flags & ~O_NONBLOCK)), 0); > - > ASSERT_EQ(sys_waitid(P_PIDFD, pidfd, &info, WEXITED, NULL), 0); > ASSERT_EQ(info.si_signo, SIGCHLD); > ASSERT_EQ(info.si_code, CLD_EXITED); > - Naresh > Christian