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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17F95E7718F for ; Fri, 27 Dec 2024 09:12:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 22FA56B007B; Fri, 27 Dec 2024 04:12:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DFA56B0082; Fri, 27 Dec 2024 04:12:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 059786B0083; Fri, 27 Dec 2024 04:12:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id DAC006B007B for ; Fri, 27 Dec 2024 04:12:42 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 542BF46AB5 for ; Fri, 27 Dec 2024 09:12:42 +0000 (UTC) X-FDA: 82940170740.20.9BE7536 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 59E0140002 for ; Fri, 27 Dec 2024 09:12:07 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XajIkab0; spf=pass (imf17.hostedemail.com: domain of gmonaco@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=gmonaco@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1735290727; h=from:from:sender: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:dkim-signature; bh=uyok1e4F7ia1+xg0A3o5orA5ZahE9CNLecopvejU7xU=; b=5iZHhfFHflFiU3CnoZubVFpY3YM1pTLLKLezyGCbMw2K6ztgSJcDVYDMdFbp0C2xAnNJYC A3dGUWolkL6yRsDO0wogRBKbo3g1mXas5yTCKSe1mdmzMvbXVydtXUb00ZbsMwZE2yiH2o 3XqQgkJFkNYu+PdJCz/yXQlzou5EHVg= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=XajIkab0; spf=pass (imf17.hostedemail.com: domain of gmonaco@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=gmonaco@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1735290727; a=rsa-sha256; cv=none; b=06SF4bIWG0sItdylNFT21pGUolHOIkgpNAfp2WOlCf49PN23W13OCSipf5wdzOSEFDWobj 0ppFdNEyw+yMZQlV1BWFfkHpo0Cc6817Cu62YgBzQ3F1Su3I1FNxNABTXwaFCkQ1JjRyW+ ZDnJVcFzTwZrd7ltLNXHj3sG0OpOie8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1735290759; 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:autocrypt:autocrypt; bh=uyok1e4F7ia1+xg0A3o5orA5ZahE9CNLecopvejU7xU=; b=XajIkab0JiXqaAJtcu9bpAF4PyEMwaff1mf5t4VNBbC0IGuXFGpYyhreM/cbzKQD40K01z 6htQFFWYjh2noZxhYtB2nyMdLUeIfRPmXQVpgWzC7tPFsWP8Q3keDlI2Ag0Ush2O8dlNqr 603Lt9uPwwfhNu1O4TRwda1dvuVX2s0= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-452-bgkbnGp8OyWxiJ4UGgSKzA-1; Fri, 27 Dec 2024 04:12:37 -0500 X-MC-Unique: bgkbnGp8OyWxiJ4UGgSKzA-1 X-Mimecast-MFC-AGG-ID: bgkbnGp8OyWxiJ4UGgSKzA Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-385ded5e92aso2659527f8f.3 for ; Fri, 27 Dec 2024 01:12:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735290756; x=1735895556; h=mime-version:user-agent:content-transfer-encoding:autocrypt :references:in-reply-to:date:cc:to:from:subject:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=uyok1e4F7ia1+xg0A3o5orA5ZahE9CNLecopvejU7xU=; b=rFBo3sOOnztPo/nogUc5v015tNX6SoPCjT7CDr267Ev/efaVes8DxQTiJq6Yf0JnKD fjuj0EHSE5otU4CKVZv4fiuhfw9zp3rFDSDlvZviXw0nmhGdHTTb9Ihx1bn/CJqtSQjW qJbyGKRqwGfQezsUnW7be+88W6c2hCs8baML8DW8CG6FJVKCSdD7qtuRvdbSuhIJtcOI +K+3VGbuv7qTXx6nIca1pPKxBUk2/8agCUO5HB41jRs6sQxioXKLYat1zyh/1yzCH9CU RovYuitvfg+i1nIcByWEVc9bQoiz7JJMJw/Cz7mi9Q4/oRvp1hnIqo6u1X4p4o1S/MbZ 9cPw== X-Forwarded-Encrypted: i=1; AJvYcCWJstRg3ZvCBmyeAugBsatLjQ24sC4AzkTzPmFeF2w2ftSdioRLxRRPQdJ9y2dzgsecWNxEvTAIZw==@kvack.org X-Gm-Message-State: AOJu0YyFVVM4cMe+fVL228LygYYXiN1Jl/4osjWhscKzRJ1TUo8YT6Sv kaiBr5br5gESS4/hRX8fju+1Kcwbl15t63k9H/X6rpUVxn6+to3nMGFqsNOuSyAGnu9v/2GRPdZ 8sxrgOId8chWODpvbLs8LjxpMtGY+GVCz8nUjRAN4pGNHGyEy X-Gm-Gg: ASbGnct8nPF82L261i40A7VL5A5wNChk+E8tt9trfhPDYwrdi3TZ4LRuu7QlbxAXzUC mkSkaGj7UNezVomB+w6elC7gxZSsPW3oupyuSQGXXPhNbkIFdyYCxPfLQ6xII9ppo2ycX9piB1j 9m0ndaaz0tJBzH7baNQmymFMyUbguBaOm4v+OnyEpP+P0eq7hlG6UjWOS6oyNypPWAZ2Ed3qJ+V YqFn4KYzwtU0mw7c2YgV6f7wbJo0pWXSkMHasDU86WNL/5t3eZZlTcpE469Hp5xUiGiYW/UyN7d dvpiT5I= X-Received: by 2002:a05:6000:3cd:b0:386:1cd3:8a03 with SMTP id ffacd0b85a97d-38a222009camr18135952f8f.32.1735290756637; Fri, 27 Dec 2024 01:12:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IFAub0r28tVG55Vxu4ubPrkvfokPRI3RBbGaSu8GjzAIjt4HPLC6fNgxZ+4K21EEsfN9vWqlA== X-Received: by 2002:a05:6000:3cd:b0:386:1cd3:8a03 with SMTP id ffacd0b85a97d-38a222009camr18135927f8f.32.1735290756248; Fri, 27 Dec 2024 01:12:36 -0800 (PST) Received: from gmonaco-thinkpadt14gen3.rmtit.csb ([185.107.56.40]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8acb17sm21373733f8f.97.2024.12.27.01.12.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Dec 2024 01:12:35 -0800 (PST) Message-ID: <2b1c2b41742cf7c3b9ed86f93684acb5e4aa8ec8.camel@redhat.com> Subject: Re: [PATCH v3 3/3] rseq/selftests: Add test for mm_cid compaction From: Gabriele Monaco To: Mathieu Desnoyers , Peter Zijlstra , Ingo Molnar , linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Juri Lelli , Shuah Khan Date: Fri, 27 Dec 2024 10:12:33 +0100 In-Reply-To: References: <20241216130909.240042-1-gmonaco@redhat.com> <20241216130909.240042-4-gmonaco@redhat.com> <6c159869-8f01-4aa5-9df1-7a0d6e3c23b7@efficios.com> <83fa755bad5e607cf242cacccb58a4ea2490b8a0.camel@redhat.com> Autocrypt: addr=gmonaco@redhat.com; prefer-encrypt=mutual; keydata=mDMEZuK5YxYJKwYBBAHaRw8BAQdAmJ3dM9Sz6/Hodu33Qrf8QH2bNeNbOikqYtxWFLVm0 1a0JEdhYnJpZWxlIE1vbmFjbyA8Z21vbmFjb0ByZWRoYXQuY29tPoiZBBMWCgBBFiEEysoR+AuB3R Zwp6j270psSVh4TfIFAmbiuWMCGwMFCQWjmoAFCwkIBwICIgIGFQoJCAsCBBYCAwECHgcCF4AACgk Q70psSVh4TfJzZgD/TXjnqCyqaZH/Y2w+YVbvm93WX2eqBqiVZ6VEjTuGNs8A/iPrKbzdWC7AicnK xyhmqeUWOzFx5P43S1E1dhsrLWgP User-Agent: Evolution 3.54.2 (3.54.2-1.fc41) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: cIplEn1Mk7QvhttFQSVf_hxtooq-Nnj2zvmQhql2km4_1735290757 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: 59E0140002 X-Rspamd-Server: rspam12 X-Stat-Signature: x47mhd17tayk6aermmueahen6n3mnm79 X-Rspam-User: X-HE-Tag: 1735290727-179412 X-HE-Meta: U2FsdGVkX18M8QVVKRbbiunWoXDtNCkSt1QY7Ld5WGjxCmLpfXE0uqxfhXBGEhVTk6CZh53zIufWQfidUUEtoZ+d2dPvI3baqLI6BZpASsVCD5ZL6Qdy/1cQRw5Iu6kvhO3ztzrLTEzc7iXiBP7zTKSwcb+FvTgxOqbH8jFejnLt2BPhgYyeEv/Lz+LHwX6LL5TWSrg6/CZS4XnxacT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YYeefGA1333yTKO/usoBAJFBjM8QQTV4vOdysJO/bdfdlu1LeuG7GM5JWguMEg7WbwLYY2UDn1pLu X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, 2024-12-26 at 09:17 -0500, Mathieu Desnoyers wrote: > On 2024-12-26 04:04, Gabriele Monaco wrote: > >=20 > > On Tue, 2024-12-24 at 11:20 -0500, Mathieu Desnoyers wrote: > > > On 2024-12-16 08:09, Gabriele Monaco wrote: > > > > + if (curr_mm_cid =3D=3D 0) { > > > > + printf_verbose( > > > > + "mm_cids successfully compacted, exiting\n"); > > > > + pthread_exit(NULL); > > > > + } > > > > + usleep(RUNNER_PERIOD); > > > > + } > > > > + assert(false); > > >=20 > > > I suspect we'd want an explicit error message here > > > with an abort() rather than an assertion which can be > > > compiled-out with -DNDEBUG. > > >=20 > > > > + } > > > > + printf_verbose("cpu%d has %d and is going to terminate\n", > > > > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 sched_getcpu(), curr_mm_cid)= ; > > > > + pthread_exit(NULL); > > > > +} > > > > + > > > > +void test_mm_cid_compaction(void) > > >=20 > > > This function should return its error to the caller > > > rather than assert. > > >=20 > > > > + if (num_threads =3D=3D 1) { > > > > + printf_verbose( > > > > + "Running on a single cpu, cannot test anything\n"); > > > > + return; > > >=20 > > > This should return a value telling the caller that > > > the test is skipped (not an error per se). > > >=20 > >=20 > > Thanks for the review! > > I'm not sure how to properly handle these, but it seems to me the > > cleanest way is to use ksft_* functions to report failures and > > skipped > > tests. Other tests in rseq don't use the library but it doesn't > > seem a > > big deal if just one test is using it, for now. >=20 > For the moment, we could do like the following test which > does a skip: >=20 > void test_membarrier(void) > { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 fprintf(stderr, "rseq_of= fset_deref_addv is not implemented > on this architecture. " > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "S= kipping membarrier test.\n"); > } >=20 > We can revamp the rest of the tests to use ksft in the future. >=20 > Currently everything is driven from run_param_test.sh, and it would > require significant rework to move to ksft. >=20 > >=20 > > It gets a bit complicated to return values since we are exiting > > from > > the main thread (sure we could join the remaining /winning/ thread > > but > > we would end up with 2 threads running). The ksft_* functions solve > > this quite nicely using exit codes, though. >=20 > Then thread_running should be marked with the noreturn attribute. >=20 > test_mm_cid_compaction can indeed return if it fails in the > preparation > stages, just not when calling thread_running. >=20 > So we want test_mm_cid_compaction to return errors so main can handle > them, and we may want to move the call to thread_running directly > into main after success of test_mm_cid_compaction preparation step. >=20 > It's not like we can append any further test after this noreturn > call. >=20 Alright, I'm a bit confused now. I see how in the rseq folder there are tests in param_test (run by a shell script) and tests on their own c file that are run just as binary. For simplicity I added this new test in a separate file and I tried to mirror what the other tests are doing: all of them are calling one or more void functions from main (test_*) and some minimal initialisation (register rseq, which I believe I may not even need, since I'm already not doing it for all threads). Now, I can have my test_* function return a value and handle it from main e.g. aborting if the function returns some value, but that would require me to define some return values (e.g. abort, fail, perhaps skip) in use only for this test. It felt it more consistent to just stick to the void function and abort/exit directly from there (or return in case of skip). All other tests do use abort for errors and assert for the pass/fail condition, but since in my case nothing else can execute after, I'd say I can simply use exit(0)/exit(1) from the winning thread. What do you think? Thanks, Gabriele