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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CFEEAC433F5 for ; Fri, 26 Nov 2021 22:00:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7E0F6B0075; Fri, 26 Nov 2021 17:00:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D05426B0078; Fri, 26 Nov 2021 17:00:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7FBF6B007B; Fri, 26 Nov 2021 17:00:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0095.hostedemail.com [216.40.44.95]) by kanga.kvack.org (Postfix) with ESMTP id A3BEB6B0075 for ; Fri, 26 Nov 2021 17:00:17 -0500 (EST) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 65FCD82DF881 for ; Fri, 26 Nov 2021 22:00:07 +0000 (UTC) X-FDA: 78852449970.27.BBE8908 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf13.hostedemail.com (Postfix) with ESMTP id 0AE621046286 for ; Fri, 26 Nov 2021 22:00:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=mVe6i3/v+cqujpezlAYb0QP3ok/XczGEBz8gbXJU03U=; b=O2JWYmxJ7/f03ehjL+s7JohJC/ ynfSXmDUkqlrleL67OukKwqmvBNMKdl3qCPsf8hgCedRMFGPTn7A7Eb1BiQDlY0DDDqrpYd0yI9/R HfNvz8TLPNMXLBCJxw0WFjgSopXR5Q5lwmDahpJ7kTlsHv8MVQb04YRmzEvNbx4PBlaocgeZBJUqf jjdUkZAtkHEJInkocwoUeava42Xe+DR8u13pxi1L4mmqXg36lPFz9vnOyEBNlWnwoAHM3CN9lYU7g eJQpcFcWe4lNXYzlaWAwx3zdieeWosmMQjxuLdDjVtT13IKOIafv1FFHU9lUrRlGJv5URI3LS6IQE 2LGGE60A==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mqjFx-000mvv-WB; Fri, 26 Nov 2021 21:59:47 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 0D7F43000DD; Fri, 26 Nov 2021 22:59:45 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id EAA812D1EBB54; Fri, 26 Nov 2021 22:59:44 +0100 (CET) Date: Fri, 26 Nov 2021 22:59:44 +0100 From: Peter Zijlstra To: Thomas Gleixner Cc: Peter Oskolkov , Ingo Molnar , Andrew Morton , Dave Hansen , Andy Lutomirski , Linux Memory Management List , Linux Kernel Mailing List , linux-api@vger.kernel.org, Paul Turner , Ben Segall , Peter Oskolkov , Andrei Vagin , Jann Horn , Thierry Delisle Subject: Re: [PATCH v0.9.1 3/6] sched/umcg: implement UMCG syscalls Message-ID: References: <20211122211327.5931-1-posk@google.com> <20211122211327.5931-4-posk@google.com> <20211124200822.GF721624@worktop.programming.kicks-ass.net> <87a6hqhbgh.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87a6hqhbgh.ffs@tglx> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0AE621046286 X-Stat-Signature: bc6z7zidnc4qcj7d1uebxq5ccjs6gii5 Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=O2JWYmxJ; dmarc=none; spf=none (imf13.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org X-HE-Tag: 1637964002-205215 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Nov 26, 2021 at 10:08:14PM +0100, Thomas Gleixner wrote: > On Fri, Nov 26 2021 at 18:09, Peter Zijlstra wrote: > > + > > + if (timo) { > > + hrtimer_init_sleeper_on_stack(&timeout, tsk->umcg_clock, > > + HRTIMER_MODE_ABS); > > + hrtimer_set_expires_range_ns(&timeout.timer, (s64)timo, > > + tsk->timer_slack_ns); > > + } > > + > > + for (;;) { > > + set_current_state(TASK_INTERRUPTIBLE); > > + > > + ret = -EINTR; > > + if (signal_pending(current)) > > + break; > > + > > + /* > > + * Faults can block and scribble our wait state. > > + */ > > + pagefault_disable(); > > + if (get_user(state, &self->state)) { > > + pagefault_enable(); > > + > > + ret = -EFAULT; > > + if (page) { > > + unpin_user_page(page); > > + page = NULL; > > + break; > > + } > > + > > + if (pin_user_pages_fast((unsigned long)self, 1, 0, &page) != 1) { > > + page = NULL; > > + break; > > + } > > + > > + continue; > > + } > > + > > + if (page) { > > + unpin_user_page(page); > > + page = NULL; > > + } > > + pagefault_enable(); > > + > > + state &= UMCG_TASK_MASK; > > + if (state != UMCG_TASK_RUNNABLE) { > > + ret = 0; > > + if (state == UMCG_TASK_RUNNING) > > + break; > > + > > + ret = -EINVAL; > > + break; > > + } > > + > > + if (timo) > > + hrtimer_sleeper_start_expires(&timeout, HRTIMER_MODE_ABS); > > + > > + freezable_schedule(); > > You can replace the whole hrtimer foo with > > if (!schedule_hrtimeout_range_clock(timo ? &timo : NULL, > tsk->timer_slack_ns, > HRTIMER_MODE_ABS, > tsk->umcg_clock)) { > ret = -ETIMEOUT; > break; > } That seems to loose the freezable crud.. then again, since we're interruptible, that shouldn't matter. Lemme go do that.