Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp115421lqp; Thu, 4 Apr 2024 08:24:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5F29X1sdQXHSs6eR7mjTTsRjxn6e7/GmcwmZI1KNiSOMOoVElS8vwDKew7J9QCW6HYlR7xPjfjZVSRMmxX1iSfPwLMH6qun2XNlYcbQ== X-Google-Smtp-Source: AGHT+IHR/fj4QqzaZiQDK0nKw3RbjbhMKPHKF9NT/aka8Dadqy5nbOtnc50noW8lOqmlB/BkV1RV X-Received: by 2002:a17:903:32c7:b0:1e2:2d0c:fef0 with SMTP id i7-20020a17090332c700b001e22d0cfef0mr3580206plr.48.1712244281940; Thu, 04 Apr 2024 08:24:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712244281; cv=pass; d=google.com; s=arc-20160816; b=xwT1mwoFwsHs81haa9Vz88kWbWWZ9wYCaDS8+ThpM4I580KCSiGBo/gZ1QluSjidT/ E4fz+q9jMYdnb7od9lkbWYfklmtE+Ta9KwF2KoFxAQc9YG2Qbrc4JBX38ZuA0YhjTvSe VXXMqYgPRlx2o23lAAjyE3Rua1pjHjnb1FwHUMNoDuwNbKUUcz21NxsWGi8ihq3DQa7T MHgz8LoxIyxsQzitkHixXitpVE8L3cW6hdIHv7ZfvVtdIlGwdsLT95vWLesvhEscJdDa UNM32xu+jSSdqyqoncES0DVJz/6Lcll2q30T3ZIIjzqvzYvaMFiqyR3PfN06Br2gOjlq S52A== 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=NQJMd58pUdtgy9XOZ35rBzvDWBc5FSPJawvsuooB2RU=; fh=QM13yX5cyx0gKVLH9qgXc292C0jk7N6nZCeRL8zZxhQ=; b=P4vQH+aurtwtaM8r2tN0LxfGCXKphQQvBN7BUdY4wjtrHiBnsnAmpK715RFm+qjYjY XYrY69H0eTT0or3kQ8482cU8/yZxSjxYJCYTdXRBILytgI3Qd5xwX35FhQksLa69QGqK uxP/hDnteB7ItJZIrDGhu3UMQgGLZnTp/h+njwlBXs8gplxWUZPxZ8VxnE9MrfEn2HEZ ux6ZDnvzz2dgzxutU2JqFSyBr1v4k4ho48buZQr85SmeDOC39P/WOUxBI2YCHhB8X2Mn 1Qza/uuWsws723nzZCbd71XzqJAm2408EwOaIGcxsgnuHoYhq5Zj6b04AHdQc6cXwgA8 8yqw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i8agMKCi; 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-131659-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131659-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id lw14-20020a1709032ace00b001e2a5d98c4bsi2110964plb.396.2024.04.04.08.24.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 08:24:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131659-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=@redhat.com header.s=mimecast20190719 header.b=i8agMKCi; 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-131659-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131659-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id AECB1B271AA for ; Thu, 4 Apr 2024 14:56:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ACE281CD03; Thu, 4 Apr 2024 14:56:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i8agMKCi" 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 431191C2AD for ; Thu, 4 Apr 2024 14:56:03 +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=1712242564; cv=none; b=a3SKSYB4sKKmK5oNuq+9XaJwkXIrwpzaiyS3OA7aIhpW8Ai4OZAfRzGrsDKWxmUtha6KV6ctd3mxUMqDrpl1v9vtT3deL2eulYQIFvo2MdZNvufz53Jtu/GjSzFvSCY1xioyydZlWlJww3NRkwdzZUJFBz/4goH6Q7O9Z3Bojq0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712242564; c=relaxed/simple; bh=1CavvPgllyAa/15cVaRGGxEOJZQLKhATrB9uOUZKE7Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=SJZFskJNPZWC5Rkc/sYOGW8g/QzT8HGQ7KgM8PfnEIFfKfbx+R3rEPTMwVz5n6k6J+b06rfyBVmluWvq5m5QRbHVab5AIcCtMP8sYj5lJLywjsFVMFmfI2aAU+T/lNE5cnjn2QSUVLnOUfakw0ESovfzWE2LoiJq9owarKPwUHE= 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=i8agMKCi; 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=1712242562; 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=NQJMd58pUdtgy9XOZ35rBzvDWBc5FSPJawvsuooB2RU=; b=i8agMKCihr4fGxGvwqCrMjcZqPrxY6HUJYSiK8KHK/ucoXQOaqXUDwdzmVGWfrd4GCukt2 Gfw3YnHejZT3exTbNt51W4FWDAytKGm/wudtE9uNlGeonH7r/tcj+TvL+wT+ojvvS3byU4 akXdYsr0fAYNEdsy9vTxm7lveyHRNOo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-246-N99Y3y5yNh-I55Dli-sewA-1; Thu, 04 Apr 2024 10:55:57 -0400 X-MC-Unique: N99Y3y5yNh-I55Dli-sewA-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 1BBF088FBAB; Thu, 4 Apr 2024 14:55:57 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.225.21]) by smtp.corp.redhat.com (Postfix) with SMTP id 43CDC3C21; Thu, 4 Apr 2024 14:55:54 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Thu, 4 Apr 2024 16:54:32 +0200 (CEST) Date: Thu, 4 Apr 2024 16:54:08 +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 v6 1/2] posix-timers: Prefer delivery of signals to the current thread Message-ID: <20240404145408.GD7153@redhat.com> References: <87sf02bgez.ffs@tglx> <87r0fmbe65.ffs@tglx> <87o7aqb6uw.ffs@tglx> <87frw2axv0.ffs@tglx> 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: <87frw2axv0.ffs@tglx> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 On 04/04, Thomas Gleixner wrote: > > IOW, we cannot test this reliably at all with the current approach. Agreed! So how about a REALLY SIMPLE test-case below? Lacks error checking, should be updated to match tools/testing/selftests. Without commit bcb7ee79029dca assert(sig_cnt > SIG_CNT) fails, the very 1st tick wakes the leader up. With that commit it doesn't fail. Oleg. #include #include #include #include #include #include #define SIG_CNT 100 static volatile int sig_cnt; static void alarm_func(int sig) { ++sig_cnt; } static void *thread_func(void *arg) { // one second before the 1st tick to ensure the leader sleeps struct itimerspec val = { .it_value.tv_sec = 1, .it_value.tv_nsec = 0, .it_interval.tv_sec = 0, .it_interval.tv_nsec = 1000 * 1000, }; timer_t id; timer_create(CLOCK_PROCESS_CPUTIME_ID, NULL, &id); timer_settime(id, 0, &val, NULL); while (sig_cnt < SIG_CNT) ; // wake up the leader kill(getpid(), SIGALRM); return NULL; } int main(void) { pthread_t thread; signal(SIGALRM, alarm_func); pthread_create(&thread, NULL, thread_func, NULL); pause(); assert(sig_cnt > SIG_CNT); // likely SIG_CNT + 1 return 0; }