From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2C8DC433EF for ; Mon, 9 Sep 2019 10:24:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B038221920 for ; Mon, 9 Sep 2019 10:24:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=arista.com header.i=@arista.com header.b="KWVXJKkg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390757AbfIIKYD (ORCPT ); Mon, 9 Sep 2019 06:24:03 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:53569 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390695AbfIIKX7 (ORCPT ); Mon, 9 Sep 2019 06:23:59 -0400 Received: by mail-wm1-f68.google.com with SMTP id q19so13138615wmc.3 for ; Mon, 09 Sep 2019 03:23:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3oTy+lkWbkFFfNbPOS2AOFsjB8RXGgtp9fv0BAsW7sw=; b=KWVXJKkgFOQhTfLznVaJozh5R/o/MAC5kqv+Qml3IcuGyQxjB7qRq685l5cBV05Ipo sgDx5/qcqGjKuGr9VE0lmZRjo/HjTZbkkbXFm/HX027RXGgT8qgkUTjbTsrWFaU78863 wzESbRXN+09ou7ZrrCkHTB5+c4ETLx6aCyp21N8Pjc66pFQFBWAMgaiwDL3tp77qaRTC LYyBTNH8KtaVoQ83sVMzOlD8AG50aQKGghkExi80zGT8ETXPvABPF/W2N78ihbUogsQy WLTY1RGj/p6SaQ17it8EMedrfkaaf3HfqKRE7kznmLO5rNb9bMj7AYrYWpRKlNzPSiQM +LqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3oTy+lkWbkFFfNbPOS2AOFsjB8RXGgtp9fv0BAsW7sw=; b=r2eC1VsWZQmPtf7rs4owBkho+jGmwCxDh25HcCL+YxXp+C5Lz0T2Jv+7lrX1fmhVxv 0+h5+QVEYyTNrNfpYkB462eR6/mVRm5tW9oKQzsKs9SW54jlAlUvc2LulC8coB5TwJZ7 n5dXfF2PxKnRSehPCMSdCtBE6IXgJsrEIcUcVz5kU5XzebOJGRLrb1wO/S3vJ8e/gaRI cyqUCNVjddSOiP4oUqsu/fCH7m7bI65cXoHMECMpd74ctYQi7F28Okrmxk5aTk7u2k3F Jp/VgMZIigtcemKB0/0zEYn5zxqqdL8HZdRKvVJwTlT500NKXy95cWYX2ficNI9Au+kN SvUQ== X-Gm-Message-State: APjAAAVmtR0+Z4X81m/aF9tjsGlxNEFnL5RxC1xXMjZ0fu4OjVhJz996 DqVmbC6ztDxfK4lluImhxTVrCVnOqi8HYw== X-Google-Smtp-Source: APXvYqwkEm9NakHd5yjJLZAfHiHfqUsqd4ZN6ARrN70g1pNUadQK+lUNEg6XugNBQoIbW5DPuRGGdw== X-Received: by 2002:a1c:1aca:: with SMTP id a193mr19207427wma.120.1568024636323; Mon, 09 Sep 2019 03:23:56 -0700 (PDT) Received: from Mindolluin.localdomain ([148.69.85.38]) by smtp.gmail.com with ESMTPSA id d14sm1800008wrj.27.2019.09.09.03.23.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2019 03:23:55 -0700 (PDT) From: Dmitry Safonov To: linux-kernel@vger.kernel.org Cc: Dmitry Safonov <0x7f454c46@gmail.com>, Dmitry Safonov , Adrian Reber , Alexander Viro , Andrei Vagin , Andy Lutomirski , Cyrill Gorcunov , Ingo Molnar , Oleg Nesterov , Pavel Emelyanov , Thomas Gleixner , containers@lists.linux-foundation.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 9/9] restart_block: Make common timeout Date: Mon, 9 Sep 2019 11:23:40 +0100 Message-Id: <20190909102340.8592-10-dima@arista.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190909102340.8592-1-dima@arista.com> References: <20190909102340.8592-1-dima@arista.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to provide a unified API to get the leftover of timeout, the timeout for different users of restart_block can be joined. All preparations done, so move timeout out of union and convert the users. Signed-off-by: Dmitry Safonov --- fs/select.c | 10 +++++----- include/linux/restart_block.h | 4 +--- kernel/futex.c | 14 +++++++------- kernel/time/alarmtimer.c | 6 +++--- kernel/time/hrtimer.c | 6 +++--- kernel/time/posix-cpu-timers.c | 6 +++--- 6 files changed, 22 insertions(+), 24 deletions(-) diff --git a/fs/select.c b/fs/select.c index ff2b9c4865cd..9ab6fc6fb7c5 100644 --- a/fs/select.c +++ b/fs/select.c @@ -1001,7 +1001,7 @@ static long do_restart_poll(struct restart_block *restart_block) { struct pollfd __user *ufds = restart_block->poll.ufds; int nfds = restart_block->poll.nfds; - ktime_t timeout = restart_block->poll.timeout; + ktime_t timeout = restart_block->timeout; int ret; ret = do_sys_poll(ufds, nfds, timeout); @@ -1030,10 +1030,10 @@ SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds, struct restart_block *restart_block; restart_block = ¤t->restart_block; - restart_block->fn = do_restart_poll; - restart_block->poll.ufds = ufds; - restart_block->poll.nfds = nfds; - restart_block->poll.timeout = timeout; + restart_block->fn = do_restart_poll; + restart_block->poll.ufds = ufds; + restart_block->poll.nfds = nfds; + restart_block->timeout = timeout; ret = -ERESTART_RESTARTBLOCK; } diff --git a/include/linux/restart_block.h b/include/linux/restart_block.h index 63d647b65395..02f90ab00a2d 100644 --- a/include/linux/restart_block.h +++ b/include/linux/restart_block.h @@ -27,6 +27,7 @@ enum timespec_type { * userspace tricks in the union. */ struct restart_block { + s64 timeout; long (*fn)(struct restart_block *); union { /* For futex_wait and futex_wait_requeue_pi */ @@ -35,7 +36,6 @@ struct restart_block { u32 val; u32 flags; u32 bitset; - u64 time; } futex; /* For nanosleep */ struct { @@ -45,11 +45,9 @@ struct restart_block { struct __kernel_timespec __user *rmtp; struct old_timespec32 __user *compat_rmtp; }; - u64 expires; } nanosleep; /* For poll */ struct { - u64 timeout; struct pollfd __user *ufds; int nfds; } poll; diff --git a/kernel/futex.c b/kernel/futex.c index 6d50728ef2e7..0738167e4911 100644 --- a/kernel/futex.c +++ b/kernel/futex.c @@ -2755,12 +2755,12 @@ static int futex_wait(u32 __user *uaddr, unsigned int flags, u32 val, goto out; restart = ¤t->restart_block; - restart->fn = futex_wait_restart; - restart->futex.uaddr = uaddr; - restart->futex.val = val; - restart->futex.time = *abs_time; - restart->futex.bitset = bitset; - restart->futex.flags = flags | FLAGS_HAS_TIMEOUT; + restart->fn = futex_wait_restart; + restart->futex.uaddr = uaddr; + restart->futex.val = val; + restart->timeout = *abs_time; + restart->futex.bitset = bitset; + restart->futex.flags = flags | FLAGS_HAS_TIMEOUT; ret = -ERESTART_RESTARTBLOCK; @@ -2779,7 +2779,7 @@ static long futex_wait_restart(struct restart_block *restart) ktime_t t, *tp = NULL; if (restart->futex.flags & FLAGS_HAS_TIMEOUT) { - t = restart->futex.time; + t = restart->timeout; tp = &t; } restart->fn = do_no_restart_syscall; diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 57518efc3810..148b187c371e 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -763,7 +763,7 @@ alarm_init_on_stack(struct alarm *alarm, enum alarmtimer_type type, static long __sched alarm_timer_nsleep_restart(struct restart_block *restart) { enum alarmtimer_type type = restart->nanosleep.clockid; - ktime_t exp = restart->nanosleep.expires; + ktime_t exp = restart->timeout; struct alarm alarm; alarm_init_on_stack(&alarm, type, alarmtimer_nsleep_wakeup); @@ -816,9 +816,9 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags, if (flags == TIMER_ABSTIME) return -ERESTARTNOHAND; - restart->fn = alarm_timer_nsleep_restart; + restart->fn = alarm_timer_nsleep_restart; restart->nanosleep.clockid = type; - restart->nanosleep.expires = exp; + restart->timeout = exp; return ret; } diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c index 4ba2b50d068f..18d4b0cc919c 100644 --- a/kernel/time/hrtimer.c +++ b/kernel/time/hrtimer.c @@ -1709,7 +1709,7 @@ static long __sched hrtimer_nanosleep_restart(struct restart_block *restart) hrtimer_init_on_stack(&t.timer, restart->nanosleep.clockid, HRTIMER_MODE_ABS); - hrtimer_set_expires_tv64(&t.timer, restart->nanosleep.expires); + hrtimer_set_expires_tv64(&t.timer, restart->timeout); ret = do_nanosleep(&t, HRTIMER_MODE_ABS); destroy_hrtimer_on_stack(&t.timer); @@ -1741,9 +1741,9 @@ long hrtimer_nanosleep(const struct timespec64 *rqtp, } restart = ¤t->restart_block; - restart->fn = hrtimer_nanosleep_restart; + restart->fn = hrtimer_nanosleep_restart; restart->nanosleep.clockid = t.timer.base->clockid; - restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer); + restart->timeout = hrtimer_get_expires_tv64(&t.timer); out: destroy_hrtimer_on_stack(&t.timer); return ret; diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c index b4dddf74dd15..691de00107c2 100644 --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -1332,8 +1332,8 @@ static int do_cpu_nanosleep(const clockid_t which_clock, int flags, * Report back to the user the time still remaining. */ restart = ¤t->restart_block; - restart->fn = posix_cpu_nsleep_restart; - restart->nanosleep.expires = expires; + restart->fn = posix_cpu_nsleep_restart; + restart->timeout = expires; if (restart->nanosleep.type != TT_NONE) error = nanosleep_copyout(restart, &it.it_value); } @@ -1372,7 +1372,7 @@ static long posix_cpu_nsleep_restart(struct restart_block *restart_block) clockid_t which_clock = restart_block->nanosleep.clockid; struct timespec64 t; - t = ns_to_timespec64(restart_block->nanosleep.expires); + t = ns_to_timespec64(restart_block->timeout); return do_cpu_nanosleep(which_clock, TIMER_ABSTIME, &t); } -- 2.23.0