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 picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D6ECCC433FE for ; Thu, 10 Nov 2022 09:19:13 +0000 (UTC) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 6C4793CD631 for ; Thu, 10 Nov 2022 10:19:11 +0100 (CET) Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 194663CA9A3 for ; Thu, 10 Nov 2022 10:19:00 +0100 (CET) Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60067.outbound.protection.outlook.com [40.107.6.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id D6D291A010F4 for ; Thu, 10 Nov 2022 10:18:58 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hEhZzGZfOdiebZyvBPN+Kg1dX5AjzN2WtRlq7qHRA+tdMnqbrWxU3ziZuFnfx3h+gnEjisfzAkqGey00+UekBeXxv8XxNg+sjJXkVhChROW9joTiKJPyawDsMI+Ls1GPkFFO2cLFNDHZJmGeLwfoRHrOvEgLr3tKVTDagFbqL5Qe3gIaCifxDFeYZ/4b1SPIGl52tB13ewDNXDVgDfmMdjMjCfLMV9dCABmsf5oszjhLlsoAsvd5TN2zbUnvC+qFAOZhMJ5ZN8A5pQKHf3PW2ggRDlMtq2oCDuW7Zwut/d6kaaBF4Inzywthfo4zxFJg2AimEiyeHzXH8Igc5ybxHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=g346hAa59i4U3im9q8BcVbRDGb2QlHuWgJCin7OQ+CI=; b=JQ5N+UhaTEgkdDd/eNWidPVNopKaLAKBrH85GMUn8sjy2BqH+dlAQz6ZVSbp6ApRx+zvzeoKTx7DzM/Lhxy95rIt5wrrdC+JpAinpMJjJ3v1iKrarjgpGkc4GFMfJyLEhVrIqLi4HixqgH4JqkrJXi2J0w/skrKlsTfLpVjAZDpokaKYEX1WV0d9AQ102HTBf5Lf2AQwSEaXCKH8BfHqzP+qgbJJaPnsyLV64tPMBULRsbEvIYtShFxScbDUAwmE0ggb5YPZUP68v6vu63ZIDYXsyCjMdriGJSKyJPI3rZl98omgJJCYNubBFx5SzR5IM6vEwV9IUSN5ClgR1BGYOw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g346hAa59i4U3im9q8BcVbRDGb2QlHuWgJCin7OQ+CI=; b=5Ux3wBBqPnaF0FGFwaMJ1Bgv3txjtuwJ4aoJr/ExnT4ql8yTlA7zLan2wbguPENtmLWNMfcFP0sP2E4AxsTdD5MmprioSiQJ+NalIQOx3IqAazNRxCHMy0fduWIds+itdbf71BfJOu2fDXktGTSfYvqguWFH8vglaPjCPEkGYF8llwt6kuosyt5PFsIY1vHqJpKabPCXQrKf07lDvIH66wKyGCJwpLwrBbZMzlKAPJsDfBeiUcA1SgXxK6q6IVwdYr/9RcEKs2SgbvvIjaGWUADPDI3wJf3/Eog3pFEtyufTene3Z1gEt2Ksjhsrw8X83pfc3c10eWA2ZimcNOqoMA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com; Received: from VI1PR04MB6797.eurprd04.prod.outlook.com (2603:10a6:803:13e::13) by PAXPR04MB8800.eurprd04.prod.outlook.com (2603:10a6:102:20f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Thu, 10 Nov 2022 09:18:56 +0000 Received: from VI1PR04MB6797.eurprd04.prod.outlook.com ([fe80::252e:5914:3caf:6257]) by VI1PR04MB6797.eurprd04.prod.outlook.com ([fe80::252e:5914:3caf:6257%4]) with mapi id 15.20.5791.027; Thu, 10 Nov 2022 09:18:56 +0000 Message-ID: Date: Thu, 10 Nov 2022 10:17:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 To: Li Wang References: <20221107110123.16369-1-andrea.cervesato@suse.com> Content-Language: en-US In-Reply-To: X-ClientProxiedBy: FR3P281CA0074.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1f::12) To VI1PR04MB6797.eurprd04.prod.outlook.com (2603:10a6:803:13e::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB6797:EE_|PAXPR04MB8800:EE_ X-MS-Office365-Filtering-Correlation-Id: 410d8bd1-6d18-4100-d80f-08dac2fc97bc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1ZaF7BmZhGzzBv43levkeMXbPrE8PmsoourTfKSSkNvcqo0LccV4WvmndWDCSZ29j2DrmpIAFpPEFe9JvHRkgV1oWHwzxCwJNaAek9uwW8HOhjWTTUwiBevTp0HAEwfDRaADqBfadEAl7oY0NiTcOs6XvTuM3CYLcLlnNEPoMCD+4ETRyqNyRxMNQPAMk12k2IPp5gOtMtnOfMnAaK1jPnGGnD5UOkDNi9TGIWOW9TLa3MGr5ACeX+vDBnndb2lQtvXxw3ltRl6eqxYENuJUQR/o4hP1Dd5npIzlBlS1wTBEPzQfG0mixzMcjs3wifdeVGwuBarBxvS8KrduY1pEcKClr2Eu3BbB3TViJKKtmxzc/KRA//VHWVwCZ0bd/P3IB3+RsGY0P6cx6iP3x6VM2bThWowWhS7XB7AAvyD82LX4IJz9c3Fwf3ht9V7WX+JXfmifLTL2vWBSfHo8TnXh4LPVc55NNDqYL4KIzVHJqKwVRHkMFlEngxWdm3s4HQaIg0fND8UQZXyxkNawmq+d4eBsRJtpoLiQc6teswoe4GSZqpDuKNglEWyojFTk+egd9O5v6G6ZoWd6bg7g6yOG2fHMOgGDxAxoGpttk4a3pt0YoykcpM+nOTcELKd6QrwZOO5iHEz54ENqUguya0thP59Klzl4+ReRw1y22uze4/JwRYhmbFUGuXxL9tkgb+VyulI+5geiKMUUyFR2gPkWqwf6sCmOJ8gq6W8c+4iyb4aGWwmU1GHMZz9YVENGTQoisaj41uzbeTfLYYG97FlbwuBeziaPPrexQdSwFjO/RQ5rrI64yhR6o/gadQT5u8Zh X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB6797.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(396003)(39860400002)(376002)(136003)(346002)(366004)(451199015)(38100700002)(2906002)(44832011)(86362001)(31696002)(166002)(4326008)(6506007)(6666004)(26005)(2616005)(53546011)(478600001)(33964004)(6512007)(316002)(66556008)(6916009)(966005)(8676002)(66476007)(6486002)(54906003)(8936002)(66946007)(5660300002)(186003)(36756003)(83380400001)(41300700001)(31686004)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-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eWRNV2YvcG5QL2k0YkE4YVpKMXExRTlRSGQ5VVUrWlZHb3BsZFZPbm5X?= =?utf-8?B?aWJ2Unh2Y3g0YWsyU3B6NU5rR2ExZVI5NmowTW9sRmJBNk9tUk5EUW93bkJZ?= =?utf-8?B?R0RwOHY1Ykk0R01BbkdwNFAyaG5XTkp0VGdUbkVNNVQ1TWNsenZQRnJyRkFL?= =?utf-8?B?UlcxbG5ObjAyWHZkVTdZMG4vQUlLWXZpYklvQ0VKanZEL2t5UUczelZ1eFZp?= =?utf-8?B?alFrYWo5aUgvdS9aVk5GcHZzZVpnOHFPeGJWYXdXdDVBam12MC8rZlJvdGZj?= =?utf-8?B?ZFphVFdBWVF6eWMzQVhQcGQyZm8vSWZ0eFhSbEpxeFFBK1NhdnE1ZzAvTm5M?= =?utf-8?B?MjNFOWcreUhGazNFWlZqakZFU093U29lSFltYUd2R0RlQUZQcGJNRFdaaE5h?= =?utf-8?B?MHc9PQ==?= X-OriginatorOrg: suse.com X-MS-Exchange-CrossTenant-Network-Message-Id: 410d8bd1-6d18-4100-d80f-08dac2fc97bc X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB6797.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Nov 2022 09:18:56.1504 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: f7a17af6-1c5c-4a36-aa8b-f5be247aa4ba X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: X4tmK7xUPmsQ27E/Bxu+WNS0BtOJO2ERdiHeBROldjRU26ANbKhd4crwBZpmjylCm8+BY6bLAt3WCDcIqmxjgEJv/AduMSbGHZ8PjL4fCI8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8800 X-Virus-Scanned: clamav-milter 0.102.4 at in-3.smtp.seeweb.it X-Virus-Status: Clean Subject: Re: [LTP] [PATCH v2] Correctly check setitimer params in setitimer01 X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Andrea Cervesato via ltp Reply-To: Andrea Cervesato Cc: ltp@lists.linux.it Content-Type: multipart/mixed; boundary="===============1745271462==" Errors-To: ltp-bounces+ltp=archiver.kernel.org@lists.linux.it Sender: "ltp" --===============1745271462== Content-Type: multipart/alternative; boundary="------------sjUVQfcc03pAhsRvxRwhjm8F" Content-Language: en-US --------------sjUVQfcc03pAhsRvxRwhjm8F Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi! On 11/10/22 08:01, Li Wang wrote: > Hi Andrea, > > On Mon, Nov 7, 2022 at 7:03 PM Andrea Cervesato via ltp > wrote: > > We use CLOCK_MONOTONIC_COARSE as our time resolution for checking > setitimer counter boundaries. > > Signed-off-by: Andrea Cervesato > --- > Switching to CLOCK_MONOTONIC_COARSE for setitimer time resolution. > >  .../kernel/syscalls/setitimer/setitimer01.c   | 33 > +++++++++++-------- >  1 file changed, 19 insertions(+), 14 deletions(-) > > diff --git a/testcases/kernel/syscalls/setitimer/setitimer01.c > b/testcases/kernel/syscalls/setitimer/setitimer01.c > index eb62f02c6..5c880c6ef 100644 > --- a/testcases/kernel/syscalls/setitimer/setitimer01.c > +++ b/testcases/kernel/syscalls/setitimer/setitimer01.c > @@ -8,7 +8,7 @@ >  /*\ >   * [Description] >   * > - * Spawn a child and verify that setitimer() syscall passes, and > it ends up > + * Spawn a child, verify that setitimer() syscall passes and it > ends up >   * counting inside expected boundaries. Then verify from the > parent that our >   * syscall sent the correct signal to the child. >   */ > @@ -22,7 +22,8 @@ >  #include "tst_safe_clocks.h" > >  static struct itimerval *value, *ovalue; > -static unsigned long time_step; > +static long time_step; > +static long time_count; > >  static struct tcase { >         int which; > @@ -56,7 +57,6 @@ static void verify_setitimer(unsigned int i) >  { >         pid_t pid; >         int status; > -       int usec = 3 * time_step; >         struct tcase *tc = &tcases[i]; > >         pid = SAFE_FORK(); > @@ -66,7 +66,7 @@ static void verify_setitimer(unsigned int i) > >                 tst_no_corefile(0); > > -               set_setitimer_value(usec, 0); > +               set_setitimer_value(time_count, 0); >                 TST_EXP_PASS(sys_setitimer(tc->which, value, NULL)); > >                 set_setitimer_value(5 * time_step, 7 * time_step); > > > Maybe we can use 'time_count' instead of 'time_step' as well. > This is needed if we want to check when setitimer syscall overrides value/ovalue on failure. We always expect time_count to be set in this case. > @@ -76,7 +76,7 @@ static void verify_setitimer(unsigned int i) >                         ovalue->it_value.tv_sec, >                         ovalue->it_value.tv_usec); > > -               if (ovalue->it_value.tv_sec != 0 || > ovalue->it_value.tv_usec > usec) > +               if (ovalue->it_value.tv_sec != 0 || > ovalue->it_value.tv_usec > time_count + time_step) > > > This is not correct for 'ITIMER_REAL', kernel does _not_ > add that one jiffy when using high resolution. I'd suggest > taking reference to Martin's code in the last email thread. > > And, I also think we'd better insert code comments here to > briefly declare why need to add the time_step for the result > (of ITIMER_VIRTUAL/ITIMER_PROF) comparison, otherwise, > people who are not familiar with this test will be confused. Sure, I agree this this > >                         tst_res(TFAIL, "Ending counters are out of > range"); > >                 for (;;) > @@ -93,24 +93,29 @@ static void verify_setitimer(unsigned int i) > >  static void setup(void) >  { > -       struct timespec res; > +       struct timespec time_res; > > -       SAFE_CLOCK_GETRES(CLOCK_MONOTONIC, &res); > +       SAFE_CLOCK_GETRES(CLOCK_MONOTONIC_COARSE, &time_res); > > > And here require code comments on why we choose to > use CLOCK_MONOTONIC_COARSE. > > > -       time_step = res.tv_nsec / 1000; > -       if (time_step < 10000) > -               time_step = 10000; > +       time_step = time_res.tv_nsec / 1000; > +       if (time_step <= 0) > +               time_step = 1000; > > -       tst_res(TINFO, "clock resolution: %luns, time step: %luus", > -               res.tv_nsec, > -               time_step); > +       time_count = 3 * time_step; > + > +       tst_res(TINFO, "clock resolution: %luns, " > +               "time step: %luus, " > +               "time count: %luus", > +               time_res.tv_nsec, > +               time_step, > +               time_count); >  } > >  static struct tst_test test = { >         .tcnt = ARRAY_SIZE(tcases), >         .forks_child = 1, > -       .test = verify_setitimer, >         .setup = setup, > +       .test = verify_setitimer, >         .bufs = (struct tst_buffers[]) { >                 {&value,  .size = sizeof(struct itimerval)}, >                 {&ovalue, .size = sizeof(struct itimerval)}, > -- > 2.35.3 > > > -- > Mailing list info: https://lists.linux.it/listinfo/ltp > > > > -- > Regards, > Li Wang Andrea --------------sjUVQfcc03pAhsRvxRwhjm8F Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit
Hi!

On 11/10/22 08:01, Li Wang wrote:
Hi Andrea,

On Mon, Nov 7, 2022 at 7:03 PM Andrea Cervesato via ltp <ltp@lists.linux.it> wrote:
We use CLOCK_MONOTONIC_COARSE as our time resolution for checking
setitimer counter boundaries.

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
Switching to CLOCK_MONOTONIC_COARSE for setitimer time resolution.

 .../kernel/syscalls/setitimer/setitimer01.c   | 33 +++++++++++--------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/testcases/kernel/syscalls/setitimer/setitimer01.c b/testcases/kernel/syscalls/setitimer/setitimer01.c
index eb62f02c6..5c880c6ef 100644
--- a/testcases/kernel/syscalls/setitimer/setitimer01.c
+++ b/testcases/kernel/syscalls/setitimer/setitimer01.c
@@ -8,7 +8,7 @@
 /*\
  * [Description]
  *
- * Spawn a child and verify that setitimer() syscall passes, and it ends up
+ * Spawn a child, verify that setitimer() syscall passes and it ends up
  * counting inside expected boundaries. Then verify from the parent that our
  * syscall sent the correct signal to the child.
  */
@@ -22,7 +22,8 @@
 #include "tst_safe_clocks.h"

 static struct itimerval *value, *ovalue;
-static unsigned long time_step;
+static long time_step;
+static long time_count;

 static struct tcase {
        int which;
@@ -56,7 +57,6 @@ static void verify_setitimer(unsigned int i)
 {
        pid_t pid;
        int status;
-       int usec = 3 * time_step;
        struct tcase *tc = &tcases[i];

        pid = SAFE_FORK();
@@ -66,7 +66,7 @@ static void verify_setitimer(unsigned int i)

                tst_no_corefile(0);

-               set_setitimer_value(usec, 0);
+               set_setitimer_value(time_count, 0);
                TST_EXP_PASS(sys_setitimer(tc->which, value, NULL));

                set_setitimer_value(5 * time_step, 7 * time_step);

Maybe we can use 'time_count' instead of 'time_step' as well.

This is needed if we want to check when setitimer syscall overrides value/ovalue on failure. We always expect time_count to be set in this case.

 
@@ -76,7 +76,7 @@ static void verify_setitimer(unsigned int i)
                        ovalue->it_value.tv_sec,
                        ovalue->it_value.tv_usec);

-               if (ovalue->it_value.tv_sec != 0 || ovalue->it_value.tv_usec > usec)
+               if (ovalue->it_value.tv_sec != 0 || ovalue->it_value.tv_usec > time_count + time_step)

This is not correct for 'ITIMER_REAL', kernel does _not_
add that one jiffy when using high resolution. I'd suggest
taking reference to Martin's code in the last email thread.

And, I also think we'd better insert code comments here to
briefly declare why need to add the time_step for the result 
(of ITIMER_VIRTUAL/ITIMER_PROF) comparison, otherwise, 
people who are not familiar with this test will be confused.
Sure, I agree this this

 
                        tst_res(TFAIL, "Ending counters are out of range");

                for (;;)
@@ -93,24 +93,29 @@ static void verify_setitimer(unsigned int i)

 static void setup(void)
 {
-       struct timespec res;
+       struct timespec time_res;

-       SAFE_CLOCK_GETRES(CLOCK_MONOTONIC, &res);
+       SAFE_CLOCK_GETRES(CLOCK_MONOTONIC_COARSE, &time_res);

And here require code comments on why we choose to
use CLOCK_MONOTONIC_COARSE.

 

-       time_step = res.tv_nsec / 1000;
-       if (time_step < 10000)
-               time_step = 10000;
+       time_step = time_res.tv_nsec / 1000;
+       if (time_step <= 0)
+               time_step = 1000;

-       tst_res(TINFO, "clock resolution: %luns, time step: %luus",
-               res.tv_nsec,
-               time_step);
+       time_count = 3 * time_step;
+
+       tst_res(TINFO, "clock resolution: %luns, "
+               "time step: %luus, "
+               "time count: %luus",
+               time_res.tv_nsec,
+               time_step,
+               time_count);
 }

 static struct tst_test test = {
        .tcnt = ARRAY_SIZE(tcases),
        .forks_child = 1,
-       .test = verify_setitimer,
        .setup = setup,
+       .test = verify_setitimer,
        .bufs = (struct tst_buffers[]) {
                {&value,  .size = sizeof(struct itimerval)},
                {&ovalue, .size = sizeof(struct itimerval)},
--
2.35.3


--
Mailing list info: https://lists.linux.it/listinfo/ltp



--
Regards,
Li Wang

Andrea

--------------sjUVQfcc03pAhsRvxRwhjm8F-- --===============1745271462== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- Mailing list info: https://lists.linux.it/listinfo/ltp --===============1745271462==--