Merge branch 'akpm' (patches from Andrew)
Merge still more updates from Andrew Morton: "18 patches. Subsystems affected by this patch series: mm (memcg and cleanups) and epoll" * emailed patches from Andrew Morton <akpm@linux-foundation.org>: mm/Kconfig: fix spelling mistake "whats" -> "what's" selftests/filesystems: expand epoll with epoll_pwait2 epoll: wire up syscall epoll_pwait2 epoll: add syscall epoll_pwait2 epoll: convert internal api to timespec64 epoll: eliminate unnecessary lock for zero timeout epoll: replace gotos with a proper loop epoll: pull all code between fetch_events and send_event into the loop epoll: simplify and optimize busy loop logic epoll: move eavail next to the list_empty_careful check epoll: pull fatal signal checks into ep_send_events() epoll: simplify signal handling epoll: check for events when removing a timed out thread from the wait queue mm/memcontrol:rewrite mem_cgroup_page_lruvec() mm, kvm: account kvm_vcpu_mmap to kmemcg mm/memcg: remove unused definitions mm/memcg: warning on !memcg after readahead page charged mm/memcg: bail early from swap accounting if memcg disabled
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <asm/unistd.h>
|
||||
#include <linux/time_types.h>
|
||||
#include <poll.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
@@ -21,6 +23,19 @@ struct epoll_mtcontext
|
||||
pthread_t waiter;
|
||||
};
|
||||
|
||||
#ifndef __NR_epoll_pwait2
|
||||
#define __NR_epoll_pwait2 -1
|
||||
#endif
|
||||
|
||||
static inline int sys_epoll_pwait2(int fd, struct epoll_event *events,
|
||||
int maxevents,
|
||||
const struct __kernel_timespec *timeout,
|
||||
const sigset_t *sigset, size_t sigsetsize)
|
||||
{
|
||||
return syscall(__NR_epoll_pwait2, fd, events, maxevents, timeout,
|
||||
sigset, sigsetsize);
|
||||
}
|
||||
|
||||
static void signal_handler(int signum)
|
||||
{
|
||||
}
|
||||
@@ -3377,4 +3392,61 @@ TEST(epoll61)
|
||||
close(ctx.evfd);
|
||||
}
|
||||
|
||||
/* Equivalent to basic test epoll1, but exercising epoll_pwait2. */
|
||||
TEST(epoll62)
|
||||
{
|
||||
int efd;
|
||||
int sfd[2];
|
||||
struct epoll_event e;
|
||||
|
||||
ASSERT_EQ(socketpair(AF_UNIX, SOCK_STREAM, 0, sfd), 0);
|
||||
|
||||
efd = epoll_create(1);
|
||||
ASSERT_GE(efd, 0);
|
||||
|
||||
e.events = EPOLLIN;
|
||||
ASSERT_EQ(epoll_ctl(efd, EPOLL_CTL_ADD, sfd[0], &e), 0);
|
||||
|
||||
ASSERT_EQ(write(sfd[1], "w", 1), 1);
|
||||
|
||||
EXPECT_EQ(sys_epoll_pwait2(efd, &e, 1, NULL, NULL, 0), 1);
|
||||
EXPECT_EQ(sys_epoll_pwait2(efd, &e, 1, NULL, NULL, 0), 1);
|
||||
|
||||
close(efd);
|
||||
close(sfd[0]);
|
||||
close(sfd[1]);
|
||||
}
|
||||
|
||||
/* Epoll_pwait2 basic timeout test. */
|
||||
TEST(epoll63)
|
||||
{
|
||||
const int cfg_delay_ms = 10;
|
||||
unsigned long long tdiff;
|
||||
struct __kernel_timespec ts;
|
||||
int efd;
|
||||
int sfd[2];
|
||||
struct epoll_event e;
|
||||
|
||||
ASSERT_EQ(socketpair(AF_UNIX, SOCK_STREAM, 0, sfd), 0);
|
||||
|
||||
efd = epoll_create(1);
|
||||
ASSERT_GE(efd, 0);
|
||||
|
||||
e.events = EPOLLIN;
|
||||
ASSERT_EQ(epoll_ctl(efd, EPOLL_CTL_ADD, sfd[0], &e), 0);
|
||||
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = cfg_delay_ms * 1000 * 1000;
|
||||
|
||||
tdiff = msecs();
|
||||
EXPECT_EQ(sys_epoll_pwait2(efd, &e, 1, &ts, NULL, 0), 0);
|
||||
tdiff = msecs() - tdiff;
|
||||
|
||||
EXPECT_GE(tdiff, cfg_delay_ms);
|
||||
|
||||
close(efd);
|
||||
close(sfd[0]);
|
||||
close(sfd[1]);
|
||||
}
|
||||
|
||||
TEST_HARNESS_MAIN
|
||||
|
||||
Reference in New Issue
Block a user