Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp461231lqe; Sat, 6 Apr 2024 08:13:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWbf5W6qJ+eu9+KQBkRrwrYP/p/991UDpqxTQl4hf4MHhn8LnMyvsAt4pJO+QwAhmnJBWyj6w73B7lvbL6IvrwVm3oM364GhiMha5GD+A== X-Google-Smtp-Source: AGHT+IGrd4cR72z8XfO4gwLOtXiy95n7NilauUOerXfJ5qkmEZ31jq9Q0/duGCB/qqNeLX2R+FUU X-Received: by 2002:a05:6a00:178a:b0:6ea:bd59:7eed with SMTP id s10-20020a056a00178a00b006eabd597eedmr5187109pfg.14.1712416383420; Sat, 06 Apr 2024 08:13:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712416383; cv=pass; d=google.com; s=arc-20160816; b=j8QpsmKqQHDmPU5ToAdohuccBxEsuGProkFWeSQr7JK4CqIBOjOKOIBRwVuy9rBOnv ++G7iwvQxE2CWBqBvvetuMELg8LkeZGZz5K0r52sn/bnhAbh+N2DkhmPhtbzHVej0GH3 CDUFArTiYS6JqwgKsrI329xTQXkcQLh2MZXkjV1pPBZBQ8L6NOAfsEyrfC3/B6W4k4xk 6DhbmSk2crAcUIWcY2Yi9NIMvNO9q1akoK7iFovmZQCjQe4DkZcjMqRwf4+k5JQM5QhI g76uV7yG5T76LbaWbT9BASLMMv+rJAprBQIl0M4fZmeWmYrrpwDLMsGYEnaj9TsCUbgD PW3w== 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=BGna14aQz4iT3c7nYzBJYPjJNR/JUSUa0PJutHav/fU=; fh=QM13yX5cyx0gKVLH9qgXc292C0jk7N6nZCeRL8zZxhQ=; b=bWtVYCdDcx0VbaBXrcRy9mqikZXqbH96a9n63c4fhC6fm+A+3pqC+M44tzxuYQlmOB a9yIGpyteM9erC9yOoi4WVsvfmM8WAag4rU/zBVAuiQFayuBGRxvx36oMsR0WyX8uToB Dq2ZG8GoFyO7rvPUjG8v2n98c2FTqxDcx/BFXvEWRSYhb2U8efxMPwWdy8YC9f+75l5C XKGY06Yzb4b6xAJoECMlG+75hVxCgN6zWzIiGo+dn5BdFtYKSJ4xAFbIhlR+OUlVqWMi ef6eaQ/wkY4pfuEThbTmM5nsw6VTzNuUnaCjnGUaVhVJZd8QHY/Zle+lydveyvq6CrTE TKcA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ti290uiw; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-133967-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133967-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h1-20020a632101000000b005dc90546100si3166404pgh.295.2024.04.06.08.13.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 08:13:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133967-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Ti290uiw; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-133967-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133967-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 1AC1F282254 for ; Sat, 6 Apr 2024 15:13:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F04D39AC9; Sat, 6 Apr 2024 15:12:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Ti290uiw" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 2FE1220314 for ; Sat, 6 Apr 2024 15:12:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712416377; cv=none; b=ntM3OCZNrbF9aQuZdHTKSizDSzmeS3s4DY09r2w6saP29UlshwP0enyv4CNKBcj5VaKEBWoj5h9JPLSFhQuT5YyGzjkQtvDYp3jyQXwQh0c+5S8g7pgBmVTEu6KClja39uyxdXlxW5ExrAZVPPgCbcdnbx/Ro6aoRvvNyXBgwro= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712416377; c=relaxed/simple; bh=TGvd7DPOXBnqIHw4CG35kLdg70o6plHtI96anJSdFnM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=uv+hc+VeFuWoAifNtlBGuea0ZvtgekIT9XJ+P3URJR3Wd/4beSdz7dcL2Eo077f55S689pnVUPp0feMWjQUP0cQgWkUJVCeMkNXTb874qjdBVspXEuie5XFTSg7U81/iddVB4CHOxo3gEUzkgR+5lEU+i0zENlTuovAeJNqmGnU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Ti290uiw; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712416375; 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: in-reply-to:in-reply-to:references:references; bh=BGna14aQz4iT3c7nYzBJYPjJNR/JUSUa0PJutHav/fU=; b=Ti290uiwjcOICXD/Ce0gVw83EncMRc2DETJ+lhd8jPMkjAKvEkEFSJP1P7P6YqbQ+i7z5Q PQHPxCCgBgAEowQg655OePnrpY4gUHFQ2AZbRGsLsoX+f+dmlYQ7QTBDRJNazRnhW/x3sH tBElIagGGIpeMYzFJM0eyqNeDTeKw5w= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-130-aioIAyOMMAu4xX5FZxTryw-1; Sat, 06 Apr 2024 11:12:47 -0400 X-MC-Unique: aioIAyOMMAu4xX5FZxTryw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B957A3806061; Sat, 6 Apr 2024 15:12:46 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.226.136]) by smtp.corp.redhat.com (Postfix) with SMTP id A39DD3C20; Sat, 6 Apr 2024 15:12:43 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sat, 6 Apr 2024 17:11:21 +0200 (CEST) Date: Sat, 6 Apr 2024 17:10:58 +0200 From: Oleg Nesterov To: Thomas Gleixner Cc: John Stultz , Marco Elver , Peter Zijlstra , Ingo Molnar , "Eric W. Biederman" , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Dmitry Vyukov , kasan-dev@googlegroups.com, Edward Liaw , Carlos Llamas , Greg Kroah-Hartman Subject: Re: [PATCH] selftests/timers/posix_timers: reimplement check_timer_distribution() Message-ID: <20240406151057.GB3060@redhat.com> References: <87sf02bgez.ffs@tglx> <87r0fmbe65.ffs@tglx> <87o7aqb6uw.ffs@tglx> <87frw2axv0.ffs@tglx> <20240404145408.GD7153@redhat.com> <87le5t9f14.ffs@tglx> <20240406150950.GA3060@redhat.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: <20240406150950.GA3060@redhat.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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"); else ksft_test_result_pass("check signal distribution\n"); return 0; err: ksft_print_msg(errmsg); return -1; }