From patchwork Tue Sep 10 13:47:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 1160345 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sipsolutions.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bqzkmudr"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46SRFR4p4Yz9sNw for ; Tue, 10 Sep 2019 23:48:27 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ogFmIV4Cyqb/loeaxJi2MAhHTwoJuy4A720ANKbYbxg=; b=bqzkmudrCot3Cc npl2s5DzK5vMzQe17soPM4zke67g7JQTlpqiLdwYq8gA4s7DK/HcdIl+1hNLty4nAxH0ocQEoNiAF 6o+UnwiAz+K0olYoypxBVeeM8jOP2kcYshsf8QxoQJzEBrtu+g1qqnn21gSeawg9z5XvcNXoTVV5H weXeaUPoDUuqYQGvvD85tGlyTf6aATpPpqlazFINtH+ecPtbVqbAYQ29MC0KxhK0fZo2MXMIrMXId cxLTpwRCO5hcMOWs8wrkHvWxGuh9B99kGioRdAor0YlUl62selc/sSRsvSrk7BznJtIlNhzreORBn UjC04TeyyB7W6pMRE1yA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i7gVG-0006Lt-N5; Tue, 10 Sep 2019 13:48:18 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:191:4433::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i7gVC-0006F3-As for linux-um@lists.infradead.org; Tue, 10 Sep 2019 13:48:16 +0000 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1i7gV7-0006bX-Ke; Tue, 10 Sep 2019 15:48:09 +0200 From: Johannes Berg To: linux-um@lists.infradead.org Subject: [PATCH 1/2] um: time-travel: fix periodic timers Date: Tue, 10 Sep 2019 15:47:55 +0200 Message-Id: <1568123276-I40b0f15a0fdd0f17e6636fbfe661e0d3d52e5ef7@changeid> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190910_064814_790513_8E5AC40A X-CRM114-Status: UNSURE ( 9.53 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Johannes Berg Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Johannes Berg Signed-off-by: Johannes Berg --- arch/um/include/shared/timer-internal.h | 9 +++++++++ arch/um/kernel/process.c | 7 ++++++- arch/um/kernel/time.c | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/arch/um/include/shared/timer-internal.h b/arch/um/include/shared/timer-internal.h index 9991ec2371e4..a4d79389b223 100644 --- a/arch/um/include/shared/timer-internal.h +++ b/arch/um/include/shared/timer-internal.h @@ -43,6 +43,11 @@ static inline void time_travel_set_timer_expiry(unsigned long long expiry) { time_travel_timer_expiry = expiry; } + +static inline void time_travel_set_timer_interval(unsigned long long interval) +{ + time_travel_timer_interval = interval; +} #else #define time_travel_mode TT_MODE_OFF #define time_travel_time 0 @@ -61,6 +66,10 @@ static inline void time_travel_set_timer_expiry(unsigned long long expiry) { } +static inline void time_travel_set_timer_interval(unsigned long long interval) +{ +} + #define time_travel_timer_mode TT_TMR_DISABLED #endif diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index 6bede7888fc2..cf242fc5fe94 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c @@ -210,7 +210,12 @@ static void time_travel_sleep(unsigned long long duration) if (time_travel_mode != TT_MODE_INFCPU) os_timer_disable(); - if (time_travel_timer_mode != TT_TMR_DISABLED || + while (time_travel_timer_mode == TT_TMR_PERIODIC && + time_travel_timer_expiry < time_travel_time) + time_travel_set_timer_expiry(time_travel_timer_expiry + + time_travel_timer_interval); + + if (time_travel_timer_mode != TT_TMR_DISABLED && time_travel_timer_expiry < next) { if (time_travel_timer_mode == TT_TMR_ONESHOT) time_travel_set_timer_mode(TT_TMR_DISABLED); diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c index 234757233355..4ecabf7e54c9 100644 --- a/arch/um/kernel/time.c +++ b/arch/um/kernel/time.c @@ -65,6 +65,7 @@ static int itimer_set_periodic(struct clock_event_device *evt) if (time_travel_mode != TT_MODE_OFF) { time_travel_set_timer_mode(TT_TMR_PERIODIC); time_travel_set_timer_expiry(time_travel_time + interval); + time_travel_set_timer_interval(interval); } if (time_travel_mode != TT_MODE_INFCPU) From patchwork Tue Sep 10 13:47:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 1160347 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=sipsolutions.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eqhg2FiO"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46SRFc6dlLz9sNw for ; Tue, 10 Sep 2019 23:48:36 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Ju1u1e7ltUq7779F3RnqRQbF+E7Locv1MgIX0rhxyNg=; b=eqhg2FiOa6ezqj twQJvhRjYO14IloKUy6XBtNhWxa/I64yOjKdXP2dEqhAphjSex6k6EthYt9oxr90ENDyVqGCCy+3V K2b/rWWQ+8Tm6pEMy/3VdjQraoo34afoMwaO+bp5t9QyZNZ86bdqCi8Cdbk1YYYx2qzF1KPGMt2NO j0iweW3YcU1MRsr0AmArBGHMREdP0TO+Ciq/7oGDeK3RnWtDY9JADFIgb0k1dMl4hhEOalZCv3spA KIgNBqTc+tBYcnBoHtyxWYFT9OybZr4vJHYdGl4+WfJ4yz9L7/k5su08N7evwuTcST9hElA7CVLFK AUgvJuPOmURZ0J8Ez0fQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i7gVI-0006Mz-F8; Tue, 10 Sep 2019 13:48:20 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:191:4433::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1i7gVC-0006Ev-9Y for linux-um@lists.infradead.org; Tue, 10 Sep 2019 13:48:16 +0000 Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1i7gV7-0006bX-Vr; Tue, 10 Sep 2019 15:48:10 +0200 From: Johannes Berg To: linux-um@lists.infradead.org Subject: [PATCH 2/2] um: time-travel: restrict time update in IRQ handler Date: Tue, 10 Sep 2019 15:47:56 +0200 Message-Id: <1568123276-Iaa969e227dff394fd66cc145454590a435cf646d@changeid> X-Mailer: git-send-email 2.20.1 In-Reply-To: <1568123276-I40b0f15a0fdd0f17e6636fbfe661e0d3d52e5ef7@changeid> References: <1568123276-I40b0f15a0fdd0f17e6636fbfe661e0d3d52e5ef7@changeid> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190910_064814_782140_DA79A703 X-CRM114-Status: GOOD ( 12.20 ) X-Spam-Score: 0.4 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (0.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.4 KHOP_HELO_FCRDNS Relay HELO differs from its IP's reverse DNS X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Johannes Berg Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Johannes Berg We currently do the time updates in the timer handler, even if we just call the timer handler ourselves. In basic mode we must in fact do it there since otherwise the OS timer signal won't move time forward, but in inf-cpu mode we don't need to, and it's harder to understand. Restrict the update there to basic mode, adding a comment, and do it in the idle code otherwise. Signed-off-by: Johannes Berg --- arch/um/kernel/process.c | 9 ++++++--- arch/um/kernel/time.c | 10 +++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index cf242fc5fe94..094028720567 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c @@ -220,10 +220,13 @@ static void time_travel_sleep(unsigned long long duration) if (time_travel_timer_mode == TT_TMR_ONESHOT) time_travel_set_timer_mode(TT_TMR_DISABLED); /* - * time_travel_time will be adjusted in the timer - * IRQ handler so it works even when the signal - * comes from the OS timer + * In basic mode, time_travel_time will be adjusted in + * the timer IRQ handler so it works even when the signal + * comes from the OS timer, see there. */ + if (time_travel_mode != TT_MODE_BASIC) + time_travel_set_time(time_travel_timer_expiry); + deliver_alarm(); } else { time_travel_set_time(next); diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c index 4ecabf7e54c9..15f2e88ba927 100644 --- a/arch/um/kernel/time.c +++ b/arch/um/kernel/time.c @@ -39,7 +39,15 @@ void timer_handler(int sig, struct siginfo *unused_si, struct uml_pt_regs *regs) { unsigned long flags; - if (time_travel_mode != TT_MODE_OFF) + /* + * In basic time-travel mode we still get real interrupts + * (signals) but since we don't read time from the OS, we + * must update the simulated time here to the expiry when + * we get a signal. + * This is not the case in inf-cpu mode, since there we + * never get any real signals from the OS. + */ + if (time_travel_mode == TT_MODE_BASIC) time_travel_set_time(time_travel_timer_expiry); local_irq_save(flags);