Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1979758lqa; Tue, 30 Apr 2024 05:20:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXXdJi6DV9Vz9VFzC3RnYDxiGGj1PleBea9OdKM5psr9FJki2UlwFBhc7b03BHvewFHXL8BlI8gOgqzkGV7kSJqJ9ryp7CCbVg4QNRzjw== X-Google-Smtp-Source: AGHT+IE0GIVZ/+hQa3How1gdtEM5h/xqP/njmKugN/0dcbzoR0n2GLm+kgbuj7zhfjkIMKOuLTBk X-Received: by 2002:a17:903:2445:b0:1eb:538e:6c6e with SMTP id l5-20020a170903244500b001eb538e6c6emr9791506pls.33.1714479649862; Tue, 30 Apr 2024 05:20:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714479649; cv=pass; d=google.com; s=arc-20160816; b=k5yaaLwlQbkdxfCd4j5kdvAMjX+bjoD7DXvcTbCpq0cUaNFDqhHg/T6UfC3ZeirC4A fGFBVdtZomd/z+5+uCDRNg3PBSfLgcuUYlLwEFxzIEGXdUOc5zFjRp7jnltTrDiig6ih wVMnidrS3VseQeopnfK3zjSgzYTDYWkH24Vuz9als1sFywRLLJRQLMciQdegHF/1XkoP oojGm50xj1y0O+bEFUEH/zB+yi/BLAM5tdtb3rxHATNfgSu1H5RwbNn9F6+zibaIvzT8 8bDtcKolq5viU78W7Qvc9w0bQBap5h4HvjU2/E4HK3ny3pmV4IUP8BuJF680WhJJCo7D o4Dw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=eIItMZou3gZijgltLtFYhoVQCZ2PKY/1z8iuQSWCkW0=; fh=Vvm1lEVIqlMMGuR6BQ/28Iqs+XHLklQBd4o11GcPYYc=; b=rJwdUzjtoiE+e6sL0ssVC2CFD4CkuvlwqDnQbZjtoxxQBYGLg/oNBU0CVciWmNKYus eOmXCjpInxtkBlD+TCHyBVOAa3lyvKw7GE+olRfY1u1VVviY2q0juYUflRMLm3cUOyZu oGL9l39CvMne3PIISScAm68+9D6kYa8NRtaB9snf035jJ6HnLB2Nhs+pbsRTvOlpdbuS qtuPZx65Ap+9SKnIBlRN9F7TGDCoSg8ObP42cLMAx7W3k1V0mX+hi50iKyAtV+xEBkGi E+ApB+bhbUaOcghgFUHPZMnKH9dSBuDAMu3f9hc+EDMY6SaZ/NZUxQV/P23Ycvw3rPoY i9sg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UIjnRN8X; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163908-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163908-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id lv13-20020a1709032a8d00b001eb1d3064bfsi7516291plb.366.2024.04.30.05.20.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 05:20:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163908-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UIjnRN8X; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-163908-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163908-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id EDF66B211DB for ; Tue, 30 Apr 2024 12:20:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60B7813F44D; Tue, 30 Apr 2024 12:20:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UIjnRN8X" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 772AA13D2A6; Tue, 30 Apr 2024 12:20:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714479638; cv=none; b=eyBDS4HN0m/VISRz/g9jbRHdMHjSJGmrWY92b3k/2D8ohGN/i1+ms/1U4vkPGCSxKJCg7tUKSie3M4XwdRcPQpSUfoHRxFRozCIzguhuTlWSwBo3VXh4LledxcRsEK93NdjslZkniPzlBPpbRO7V9IjMjjvHy2xxaDJ+47gBuFU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714479638; c=relaxed/simple; bh=gkvysAfCfPH18qay0BvNJ5BN+KvihLOCCXlEpo/dq9A=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ki+MjwNe05WEiJZiWRbDEpytWF8lwiyGNVTPx9vHhrgboYEvOzdcVkMFfFvwwjJDYOXXJnwxNGJO1DEjjcxsWOOyw5C001/Fy8LJjJeycWcjtvOu1zogCD7zF2aP7phiO8XlsUJB6BjNciL10wUlVbhUtre9NIlOdZ2Jz1pI6TU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UIjnRN8X; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5AB43C2BBFC; Tue, 30 Apr 2024 12:20:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1714479638; bh=gkvysAfCfPH18qay0BvNJ5BN+KvihLOCCXlEpo/dq9A=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UIjnRN8X/xe5vUtE6o2nd9rsg8KZM0T7FDvMnFtAonzS0TY00JyKKnGNFshCo3C1w IagPyl82EAAOALf3ij4DeeZZ0HQRz72aU4Aa9QVniiLIpCrb53M+BqwtDm6rnN/65C bQdfGt9LoG++A3UPBurT5vANHdeFJoWmZqmFX8VfwVmnQKFUKV6cfyjXIXq7P9LpZX cTqb6IVIQFaZN/XW1eyJZtRBsrOQoogB0xTcMA7n3cCpekptuNt/4PuSsfCsiT6rN4 3V6JLhQ8b+VAt+YYSgTnrZCdXrEV6aMGjVDjHGSwB4SctVOg5ghXFuK84QXsAtFtQD oM1LwzViIFj8w== Date: Tue, 30 Apr 2024 13:20:32 +0100 From: Will Deacon To: Dorine Tipo Cc: Catalin Marinas , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Javier Carrasco Subject: Re: [PATCH] selftests:arm64: Test PR_SVE_VL_INHERIT after a double fork Message-ID: <20240430122032.GA13690@willie-the-truck> References: <20240429044012.5018-1-dorine.a.tipo@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240429044012.5018-1-dorine.a.tipo@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) On Mon, Apr 29, 2024 at 04:40:12AM +0000, Dorine Tipo wrote: > Add a new test, double_fork_test() to check the inheritance of the SVE > vector length after a double fork. > The `EXPECTED_TESTS` macro has been updated to account for this additional > test. > This patch addresses task 7 on the TODO list. > > Signed-off-by: Dorine Tipo > --- > tools/testing/selftests/arm64/fp/za-fork.c | 95 +++++++++++++++++++++- > 1 file changed, 94 insertions(+), 1 deletion(-) I haven't tried compiling this, but some of the code looks a little off: > diff --git a/tools/testing/selftests/arm64/fp/za-fork.c b/tools/testing/selftests/arm64/fp/za-fork.c > index 587b94648222..35229e570dcf 100644 > --- a/tools/testing/selftests/arm64/fp/za-fork.c > +++ b/tools/testing/selftests/arm64/fp/za-fork.c > @@ -11,7 +11,7 @@ > > #include "kselftest.h" > > -#define EXPECTED_TESTS 1 > +#define EXPECTED_TESTS 2 > > int fork_test(void); > int verify_fork(void); > @@ -69,6 +69,97 @@ int fork_test_c(void) > } > } > > +int double_fork_test(void) > +{ > + pid_t newpid, grandchild_pid, waiting; > + int ret, child_status, parent_result; > + > + ret = prctl(PR_SVE_SET_VL, vl | PR_SVE_VL_INHERIT); > + if (ret < 0) > + ksft_exit_fail_msg("Failed to set SVE VL %d\n", vl); > + > + newpid = fork(); > + if (newpid == 0) { > + /* In child */ > + if (!verify_fork()) { > + ksft_print_msg("ZA state invalid in child\n"); > + exit(0); > + } > + > + grandchild_pid = fork(); > + if (grandchild_pid == 0) { > + /* in grandchild */ > + if (!verfy_fork()) { > + ksft_print_msg("ZA state invalid in grandchild\n"); > + exit(0); > + } > + > + ret = prctl(PR_SVE_GET_VL); > + if (ret & PR_SVE_VL_INHERIT) { > + ksft_print_msg("prctl() reports _INHERIT\n"); > + return; Missing return value? > + } > + ksft_print_msg("prctl() does not report _INHERIT\n"); Indentation. > + > + } else if (grandchild_pid < 0) { > + ksft_print_msg("fork() failed in first child: %d\n", grandchild_pid); > + return 0; > + } > + > + /* Wait for the grandchild process to exit */ > + waiting = waitpid(grandchild_pid, &child_status, 0); > + if (waiting < 0) { > + if (errno == EINTR) > + continue; 'continue' outside of a loop? > + ksft_print_msg("waitpid() failed: %d\n", errno); > + return 0; > + } > + if (waiting != grandchild_pid) { > + ksft_print_msg("waitpid() returned wrong PID\n"); > + return 0; > + } > + > + if (!WIFEXITED(child_status)) { > + ksft_print_msg("grandchild did not exit\n"); > + return 0; > + } > + > + exit(1); > + } Stray '}' ? Will