Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3945606pxf; Tue, 6 Apr 2021 04:28:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGj3fGVh5uyF+9wucKSI1lmXI7SXmyryE8wvDC+FFj6x6gAOdzj0vzv+MZEBt1R/Sy9lnq X-Received: by 2002:aa7:c5d0:: with SMTP id h16mr37322386eds.380.1617708520946; Tue, 06 Apr 2021 04:28:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617708520; cv=none; d=google.com; s=arc-20160816; b=gfjnd1mTTraq9QvOAF2afon3nszhMmHSkbxuxw0dWwRIxo3dOmbNthfIGa5d29OILn sttOxMvIrtLQhNo8ySH8+EdUwEZjFIWE2Ps27xvFPBdWg7NW59Tre+tgsz5HPR0/zW14 HK2u1Sx8JafewYo5IqsakjBy5FgnRKjUBW1wgPTUby9aYPx+4VFxyOBDPlOzWRprZ5gd jEZ+Egbd5iziuO3oLuEkpN5mmIQjcpYVURWJ0a2cCm1u9+1AVQnsYLMkSWFUmbuJf/Oz z3/yomjS75r9wRaRWgKX+pmRAotUhbVUYbnoVPeEVdtIYMVW559mTE3nRUUbwp9+HSOS RgfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=7kFHnvx/B4Qtw7W2IVR/bkpsW2AvjD+DKFpa2JB+D7Q=; b=Z1QFN+wWay2AG6N/n67at+dIHSni5M23n3TQ4jRtYTnyTm1vkXBLEzNxwy+yNtU6MO cBWTz77ISaHfBBXwNJ1GhARnEtCd5yAoCjVUHg44gkEYUwVQv4LLht4ZWJzVlqAsTGsx W8jrLP6s5ZFmNWFC2Lh1032YZIvJmOcxdJYPsafb5heD5zde7LoeyeRAFZy0V17iGBeJ ZvQP/gyihZMbw3m4QBDPjtFQJyn+XcC/IL+6ZIM6SQhdj0jZjH95eQRP3aPL29wr08zb YDkP+yO9ZBHNXGvIh+xgnqd72Cb64I9B/Lhkq3I1KRA/AKZPr/uiOYm7iEm9VnvOM/vo LM/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do18si1886641ejc.109.2021.04.06.04.28.17; Tue, 06 Apr 2021 04:28:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241467AbhDEXKr (ORCPT + 99 others); Mon, 5 Apr 2021 19:10:47 -0400 Received: from mx2.suse.de ([195.135.220.15]:38366 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235683AbhDEXKm (ORCPT ); Mon, 5 Apr 2021 19:10:42 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4218CB148; Mon, 5 Apr 2021 23:10:35 +0000 (UTC) From: Davidlohr Bueso To: akpm@linux-foundation.org Cc: jbaron@akamai.com, rpenyaev@suse.de, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, dave@stgolabs.net, Davidlohr Bueso Subject: [PATCH 1/2] kselftest: introduce new epoll test case Date: Mon, 5 Apr 2021 16:10:24 -0700 Message-Id: <20210405231025.33829-2-dave@stgolabs.net> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210405231025.33829-1-dave@stgolabs.net> References: <20210405231025.33829-1-dave@stgolabs.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This incorporates the testcase originally reported in: https://bugzilla.kernel.org/show_bug.cgi?id=208943 Which ensures an event is reported to all threads blocked on the same epoll descriptor, otherwise only a single thread will receive the wakeup once the event become ready. Signed-off-by: Davidlohr Bueso --- .../filesystems/epoll/epoll_wakeup_test.c | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c b/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c index ad7fabd575f9..65ede506305c 100644 --- a/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c +++ b/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c @@ -3449,4 +3449,48 @@ TEST(epoll63) close(sfd[1]); } +/* + * t0 t1 + * (ew) \ / (ew) + * e0 + * | (lt) + * s0 + */ +TEST(epoll64) +{ + pthread_t waiter[2]; + struct epoll_event e; + struct epoll_mtcontext ctx = { 0 }; + + signal(SIGUSR1, signal_handler); + + ASSERT_EQ(socketpair(AF_UNIX, SOCK_STREAM, 0, ctx.sfd), 0); + + ctx.efd[0] = epoll_create(1); + ASSERT_GE(ctx.efd[0], 0); + + e.events = EPOLLIN; + ASSERT_EQ(epoll_ctl(ctx.efd[0], EPOLL_CTL_ADD, ctx.sfd[0], &e), 0); + + /* + * main will act as the emitter once both waiter threads are + * blocked and expects to both be awoken upon the ready event. + */ + ctx.main = pthread_self(); + ASSERT_EQ(pthread_create(&waiter[0], NULL, waiter_entry1a, &ctx), 0); + ASSERT_EQ(pthread_create(&waiter[1], NULL, waiter_entry1a, &ctx), 0); + + usleep(100000); + ASSERT_EQ(write(ctx.sfd[1], "w", 1), 1); + + ASSERT_EQ(pthread_join(waiter[0], NULL), 0); + ASSERT_EQ(pthread_join(waiter[1], NULL), 0); + + EXPECT_EQ(ctx.count, 2); + + close(ctx.efd[0]); + close(ctx.sfd[0]); + close(ctx.sfd[1]); +} + TEST_HARNESS_MAIN -- 2.26.2