Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1203949lqe; Mon, 8 Apr 2024 01:39:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXSCOQ7Ias0QLmG7/PtIBWpR7t5NtBA2J1d1BLD87gUIbFd7K3c/aOH0NzmNLpMPpNKxWOTmukV3ntmvKEMVR/FyRVpEQPL1SsuHkkeFw== X-Google-Smtp-Source: AGHT+IEofI/mGV/RmyAR525kkjtSLCOn7i7JFHH6HiMQXwnl6mTFbbJTwCKhEbgTkJHcxp4E721F X-Received: by 2002:a05:6a00:23d2:b0:6ec:ff1b:aa0b with SMTP id g18-20020a056a0023d200b006ecff1baa0bmr9345638pfc.18.1712565573217; Mon, 08 Apr 2024 01:39:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712565573; cv=pass; d=google.com; s=arc-20160816; b=0k3LGvSAcwsk9/EIOYtHoTK8yaMm35o8NIwI2d6cCxiE5HyVM+VRAH3ktGfuQg2dmj +GMgCee/u5oFRqLFzM/9reyhrJBWJNWGM1VrfF0udEih8+DNAnJZxc4VUkbCc8ZEcc/z VGrI7Sc/hQco0cisrZwiFIfBmi9teeF4QnCaRqOyTXCfIVTAm+50hUXmOjelNK7hJeza C5X+bSWbUJNIZHaNYdSmSHGXg0dAITIrI/y+YZCr62LOzhpKcNk1VC9JD03yhHnsA6Za lM+IB2nIUhguAnqOmD4CjZ+mtCYoYkXUdM8izDl3i4S4P56K6DmRMAF69QfIzEyp/tL1 dEZw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=W9xvn/M8xXcsYEzO1oyT+gGu7oWuytzcOqfktvcQPMI=; fh=yFjBX/tdMW2wG/17j8cU/Dcd9UhKPsMC0ArsFuU+6f8=; b=ahEFlBjqD+Y6oxc6eWGP6eKRPrOZi9BEsbUrKbkXQeSN3H6RiMIIrHGbc23yVPMuQm Tba08Zqo7oJH2zZjp4X17I5/QHcgF9ePC5kaetXyIrqJgnROs0hJJQXMhq7IVETyFOcn 4KPtBMBU0i5iPtiJK7jGg6bezXqxyYB3/+MqeVmUnKh3Mc5g53dUUirmJGjMWW4YPyep H/rhJX+QfWZsKiWcqiPoqz0wJLHiSYTB2tnW27KqN4XHZF191uYNNzGfTbIe0wuO1XJg dRE+W6zl1FHGc6RDf9ZytHiYJSyQyRizqn1BRWa8GWKKLDFPE7KtpIBAn79b0NLvRN9N kQZg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="m2tm/66T"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-135041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135041-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id v16-20020a63f210000000b005e428bf5de1si5771283pgh.749.2024.04.08.01.39.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 01:39:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="m2tm/66T"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-135041-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135041-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id D8797288578 for ; Mon, 8 Apr 2024 08:31:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A2B3838FB9; Mon, 8 Apr 2024 08:30:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="m2tm/66T" Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21B8F4084D for ; Mon, 8 Apr 2024 08:30:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712565047; cv=none; b=c8fUEJxUUNWKiExBokiWHEYsaLc1zmjdKz4Eq9mlNfCZyN+PjgkjfSwctEEUBMdVIzqVfHbZIfbEbuKOHF4aEyD+fOib5ogqFbAMD07BbG+jCY7VXXgrWIqKbXZyBf0CJyTnbzRC8lREb5iHeVYQ+o413AuNqYQ0vfb57+gho6s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712565047; c=relaxed/simple; bh=DlCB0MLCDKFbZ6OQNy2rzkZOL85cCf+2vW/rg/QwDXQ=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Jpkivlj8kBNCOM1chdSxSBlNpnIRzECVzvZaCCeiy5TVf6LnXfjP/+ucz+lMIbOA0VI/r2yGkT/MkDdPPkACR4PPdL/vr41Bm3WSHQ4Q7iWKoat6A3+FeZ+n8vu1Gfr/C/dmCTJvYXO0iUkrGpTn1meWCdbLA+exyZf66BZGa68= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=m2tm/66T; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-56e67402a3fso3232a12.0 for ; Mon, 08 Apr 2024 01:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712565044; x=1713169844; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=W9xvn/M8xXcsYEzO1oyT+gGu7oWuytzcOqfktvcQPMI=; b=m2tm/66TXfi4TtA8dT0qginmmQIuMBsFvai40coLQHtwq3175DldiQX1JLNkaU3nO7 vkGMAEpNSt/6sw8bF3tSJ96tNJxZ4B7vG4Hr9KtCU8Lu9ZQM+qqvEV+GUrZGy9N3Vf1/ 4IbWVstqqMSgU1k1ro6JYq0GHIXSaJzlMxFQ2n9pgDGZCqWlmw8YmQPeLfMKyOBR0FdG wXAemPBPS7sDTxlhpysDlCUzSE3/8L0sD+IEKKrFLD3fKw85gPtuc6e51qdtO3zlHylc 90nSBdfOJi+yCJgR2zeXkLzNwutmXZ1eUkUxQhr/jgYiROahU8N4uxcaUn1gZ1jFP16B vLdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712565044; x=1713169844; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=W9xvn/M8xXcsYEzO1oyT+gGu7oWuytzcOqfktvcQPMI=; b=L4jz0Em/sUiScR0ZlkqQUkNRdtUv5kEyNuUCN9yyM3N8vI/NLadIJRCQ+Nq4EPTUg1 cFYGZ1gJkbx5UusTdwQsQMdhSvuoOXJtJk0CYvvXC8uxzp/cuIaaPt0H2RouucTqEj4q YmCXxEW42aF8LASlIB9afMaFaXzNSJIXozgZYjebIM6BNbYTbO7Ry77BE/BpZ3UCwfHC eixFNiV7ggZG1m9Urktug8J9s5vdZcO7//PnCZ8iR1P6mjGe5mici1WuSG7bvYvwbElH 3C0zZHEejmJQw9CmBUB6n9QrRxVwQKuXtMQT7lvigk8iJSkjKp9FlpXC5pFheskSPV+6 xxNg== X-Forwarded-Encrypted: i=1; AJvYcCXJe3sGxUXY1qAJpIhXuFWrme0dnPcNIrREU7KrLEzg3ktzTpi06kD9n1o090Rrsb95xbDvnOv9Plz7NONhOLDV2klFrunt4urWg1tn X-Gm-Message-State: AOJu0YzRjp+YN8oU+UuMOuQ2Ik84GJLRLqxgqf2Uh161wB/Sl8k4GH7x hggqiUzg23ivBaOaw4AdGInk6Q0d5H7A7zrBOe0XSewwLsA0LO1s+EqAAoE4GRmnanVuhhpLcN1 T8oMUm92pUyJIbDn+bXGiwBimUyFboo8m/If4 X-Received: by 2002:a05:6402:542:b0:56e:ac4:e1f3 with SMTP id i2-20020a056402054200b0056e0ac4e1f3mr203931edx.7.1712565044222; Mon, 08 Apr 2024 01:30:44 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <87sf02bgez.ffs@tglx> <87r0fmbe65.ffs@tglx> <87o7aqb6uw.ffs@tglx> <87frw2axv0.ffs@tglx> <20240404145408.GD7153@redhat.com> <87le5t9f14.ffs@tglx> <20240406150950.GA3060@redhat.com> <20240406151057.GB3060@redhat.com> In-Reply-To: <20240406151057.GB3060@redhat.com> From: Dmitry Vyukov Date: Mon, 8 Apr 2024 10:30:32 +0200 Message-ID: Subject: Re: [PATCH] selftests/timers/posix_timers: reimplement check_timer_distribution() To: Oleg Nesterov Cc: Thomas Gleixner , John Stultz , Marco Elver , Peter Zijlstra , Ingo Molnar , "Eric W. Biederman" , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kasan-dev@googlegroups.com, Edward Liaw , Carlos Llamas , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" On Sat, 6 Apr 2024 at 17:12, Oleg Nesterov wrote: > > Dmitry, Thomas, > > To simplify the review I've attached the code with this patch applied below. > > Yes, this changes the "semantics" of check_timer_distribution(), perhaps it > should be renamed. > > But I do not see a better approach, and in fact I think that > > Test that all running threads _eventually_ receive CLOCK_PROCESS_CPUTIME_ID > > is the wrong goal. > > Do you agree? > > Oleg. > ------------------------------------------------------------------------------- > > static pthread_t ctd_thread; > static volatile int ctd_count, ctd_failed; > > static void ctd_sighandler(int sig) > { > if (pthread_self() != ctd_thread) > ctd_failed = 1; > ctd_count--; > } > > static void *ctd_thread_func(void *arg) > { > struct itimerspec val = { > .it_value.tv_sec = 0, > .it_value.tv_nsec = 1000 * 1000, > .it_interval.tv_sec = 0, > .it_interval.tv_nsec = 1000 * 1000, > }; > timer_t id; > > /* 1/10 seconds to ensure the leader sleeps */ > usleep(10000); > > ctd_count = 100; > if (timer_create(CLOCK_PROCESS_CPUTIME_ID, NULL, &id)) > return "Can't create timer"; > if (timer_settime(id, 0, &val, NULL)) > return "Can't set timer"; > > while (ctd_count > 0 && !ctd_failed) > ; > > if (timer_delete(id)) > return "Can't delete timer"; > > return NULL; > } > > /* > * Test that only the running thread receives the timer signal. > */ > static int check_timer_distribution(void) > { > const char *errmsg; > > signal(SIGALRM, ctd_sighandler); > > errmsg = "Can't create thread"; > if (pthread_create(&ctd_thread, NULL, ctd_thread_func, NULL)) > goto err; > > errmsg = "Can't join thread"; > if (pthread_join(ctd_thread, (void **)&errmsg) || errmsg) > goto err; > > if (ctd_failed) > ksft_test_result_skip("No signal distribution. Assuming old kernel\n"); Shouldn't the test fail here? The goal of a test is to fail when things don't work. I don't see any other ksft_test_result_fail() calls, and it does not look that the test will hang on incorrect distribution. > else > ksft_test_result_pass("check signal distribution\n"); > > return 0; > err: > ksft_print_msg(errmsg); > return -1; > } >