Message ID | 20231020-uml-time-backwards-v1-1-90b776fc6dfd@axis.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp1160754vqb; Fri, 20 Oct 2023 09:05:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFG7fZCOg0lA75lARQbnTnSQ2RIO/ELB9hCvpq7qeA3cFkj0JzWs/zuIZUr8i7Uo8bRkf2I X-Received: by 2002:a05:6a20:938f:b0:17a:fe0a:c66c with SMTP id x15-20020a056a20938f00b0017afe0ac66cmr7615141pzh.2.1697817949940; Fri, 20 Oct 2023 09:05:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697817949; cv=pass; d=google.com; s=arc-20160816; b=HyS7+UQHCymFBCLv5RN/kTgpmQUIOgJyMS4SCSq4ocOVyyhmcZOzMo18VwflcM+A0l AuVbRDxFzoZwWXXAIMjC7w7FSA062f8iVQp/N3gi/QvbJwCn7UtzXLwl1PVlUvDNDiSD qdIh89qNKRuP61ZUJ7i595M5++tcT6uj2FUoqImmZ5Zt8qmlt2ghGzhK1ANS4DeyJDwi N2eZnF+l0RCg+TBSSCKuRNDFOmAvNCEeRSFyoSeOYpbY6WNIvXVHuLmO4AfSABc8TrAX 4lww3VW44EFbkUiud/vMtRekEL7U0RPaSJVw/iPkq6hPDINl5wl9tzJHIgLsBDJIWj5v cKhw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=na5O4Qh8Ep60/F+xKOlkyWt1PratIgl4fxUa+ypbRuI=; fh=atbwqOWWsd1eyMcdTHUeIUuEuh2+JVPQn9gxBpDhjLU=; b=HOvpo02NGdCF3GGZKrpYkS4/SCeQyZCwY1FZIs3kdyrHf5n98wbQW5LKfI2j0d+gJh jo3+sYKwmnsx4jojFL1scNhBTsEmyA3xJN+YZCYRXL8CUC/xYZzXk5r26Pz1b+hIV3Ma QpXeHmZqEeWxgf9eFOH8v01CuiADCpVxLl9oSk1fbty52E9nbVl46TGBsu0S8J5v6TlP TXcAMFIjT4i6BMKydq+L3hKEtbSxCG9znb0uvqXoCCXkBSua1Gb56AoqPp2XpPqGX/5p 26foBVfRL/a5wOsaYReGCRbypANadi+anmLqFvlVQGF9/4sPwt/hsgeVqgKskUjR+Ttc lWog== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@axis.com header.s=selector1 header.b=EOnhz2oq; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id s194-20020a632ccb000000b005b86140eabfsi2094767pgs.186.2023.10.20.09.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 09:05:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@axis.com header.s=selector1 header.b=EOnhz2oq; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=axis.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 0CD74830D138; Fri, 20 Oct 2023 07:48:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377554AbjJTOru (ORCPT <rfc822;a1648639935@gmail.com> + 26 others); Fri, 20 Oct 2023 10:47:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377239AbjJTOrt (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 20 Oct 2023 10:47:49 -0400 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on2078.outbound.protection.outlook.com [40.107.7.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 079E0D46 for <linux-kernel@vger.kernel.org>; Fri, 20 Oct 2023 07:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WCPkh85UJrkyVGGJHxz/A+EGb7gzUIBfTE11/RPB4FTwt2LVLj+nH/JNXP49Z2l9lTpfFTSpxOaJQSOomnxSWK5zkxSCfJux6qLwNiR+w4pmNoqi3QAWQ7BBG9odBjyRo8ZONQj85rO61hTeYYGSAXFybOVSk7kcrhZX5VtRUjIZocrpJXS8W3TkdBz/2OnwIblASxXoggKSLfuqLJpBUgsEmZF0CWC6GUOTDvgSVoyDg1KY+D4bB+ekIzD2AM9FGElIFNySfYLnHwo8iGzfZ0XFgPWSe17YslURDiPg8szuneFzV3KPZxa2vs3+syqFT091IjtC9AsGgjaZmIArZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=na5O4Qh8Ep60/F+xKOlkyWt1PratIgl4fxUa+ypbRuI=; b=RFMtt3ry4vMXviz/tIs/teDbMCqnvQJNpnk1tURzQvGQRwYkbTePQuDajA2L6zXpVbWuXbJ8NQPGgCCNAfofx5GJGRjz8Wx0+fo2UarFooXPKDHvw3yL2Pq4gy2HfwiPOP0POSeeKbISLr7qiamU52QqOeezixMqk55rwHf8S1CeNskZcF6apssjI5p7Bymvrsy8Ry4/0mcZe9EggS01TfYKsa3MK1voMj+ocxnDfWCG7vuh1cMf/sBg1AoAv2ev4Y+wf1MvD/TMy8tZ1X9U4W12Yw6GrB7A4lgo9My3hOV/3YkXb7eB0fgy2NS/UQrL53pCshRgxjR/g3sNIIxDbQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 195.60.68.100) smtp.rcpttodomain=cambridgegreys.com smtp.mailfrom=axis.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=axis.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=na5O4Qh8Ep60/F+xKOlkyWt1PratIgl4fxUa+ypbRuI=; b=EOnhz2oqV6Hs03LwSqgTywPT5q1eZleBAp+dmxCjdjuZeQflbS2aIQ0hwdR1+9s8gC8cbGnOSLTn2oPqXTQJSpB7wKYdJHLFzPMSZcLLTSq+Iw6H+TcwAt5jQ8gUT8aBsMVCWJu6NlE2haFyA6xQDsqedBcZG/qRBaGXG0WTXYQ= Received: from AS9PR06CA0337.eurprd06.prod.outlook.com (2603:10a6:20b:466::13) by AS2PR02MB9692.eurprd02.prod.outlook.com (2603:10a6:20b:5e8::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Fri, 20 Oct 2023 14:47:43 +0000 Received: from AM1PEPF000252DC.eurprd07.prod.outlook.com (2603:10a6:20b:466:cafe::9e) by AS9PR06CA0337.outlook.office365.com (2603:10a6:20b:466::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6907.26 via Frontend Transport; Fri, 20 Oct 2023 14:47:43 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 195.60.68.100) smtp.mailfrom=axis.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=axis.com; Received-SPF: Fail (protection.outlook.com: domain of axis.com does not designate 195.60.68.100 as permitted sender) receiver=protection.outlook.com; client-ip=195.60.68.100; helo=mail.axis.com; Received: from mail.axis.com (195.60.68.100) by AM1PEPF000252DC.mail.protection.outlook.com (10.167.16.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6907.20 via Frontend Transport; Fri, 20 Oct 2023 14:47:43 +0000 Received: from SE-MAIL21W.axis.com (10.20.40.16) by se-mail02w.axis.com (10.20.40.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 20 Oct 2023 16:47:42 +0200 Received: from se-mail01w.axis.com (10.20.40.7) by SE-MAIL21W.axis.com (10.20.40.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Fri, 20 Oct 2023 16:47:42 +0200 Received: from se-intmail01x.se.axis.com (10.0.5.60) by se-mail01w.axis.com (10.20.40.7) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Fri, 20 Oct 2023 16:47:42 +0200 Received: from pc45945-2140.se.axis.com (pc45945-2140.se.axis.com [10.88.125.80]) by se-intmail01x.se.axis.com (Postfix) with ESMTP id 919CD367C; Fri, 20 Oct 2023 16:47:42 +0200 (CEST) Received: by pc45945-2140.se.axis.com (Postfix, from userid 10564) id 9F55E746BD68; Fri, 20 Oct 2023 16:47:42 +0200 (CEST) From: Vincent Whitchurch <vincent.whitchurch@axis.com> Date: Fri, 20 Oct 2023 16:47:39 +0200 Subject: [PATCH] um: time-travel: fix time going backwards MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-ID: <20231020-uml-time-backwards-v1-1-90b776fc6dfd@axis.com> X-B4-Tracking: v=1; b=H4sIAAqTMmUC/x3MSQqAMAxA0atI1gbaiCBeRVzUNmpwpHUC6d0tL t/i/xcCe+EAdfaC50uCbGuCzjOwo1kHRnHJQIoKrUjhucx4yMLYGTvdxruAZUm20oadowJSuHv u5fmnTRvjB9BuoQZkAAAA To: Richard Weinberger <richard@nod.at>, Anton Ivanov <anton.ivanov@cambridgegreys.com>, Johannes Berg <johannes@sipsolutions.net> CC: <linux-um@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <kernel@axis.com>, Vincent Whitchurch <vincent.whitchurch@axis.com> X-Mailer: b4 0.12.3 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM1PEPF000252DC:EE_|AS2PR02MB9692:EE_ X-MS-Office365-Filtering-Correlation-Id: b48aaed4-dcfe-49a5-3103-08dbd17b8444 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: W4VPyGoxDOT2UoW2xdLxLl19Bw2pBO2fYEXcKYqQljbgjqyUIvr8pLJ+RFCVI0DLqK36uuSMlB9z88e96pKqnS/G7YymzBPNU3gf6cBD4J69FXvFZdQIQu+svft0kjn27o0i4pOVIxe9JbY+SJbmVwtbxrr/QrR5pS8huPjOe2GEo3HQjU2GhVrle0/uWnhyllTrXu2JxeF+je7swKrYF0sdv4kRRGaOne/kQrapJScSyoAV9kmgjmRlbcWCTVRnqinU2yX33CWQX4L8bFksg7GyalQhzBpR2HIfQU30pFFGsrPBpBkUcVrD6sBFjnNSfKVi5BNvuHm2EDM0K8yL+UoXw5aAeiZmOb32mL85pn4BJ3b9rlLnfZoz4huLFeP8cSwHpFF/Fa4MB9SXtWvyOw1GCcyKHCmNgqVLmd9PVKK2O1aOob62H//waWv+PcVgPFbDYcgcxcoADU+TSTylDDfev7DCUchUH6h9fLMRmUaPfrO16lH7IE4GNHa6WAqAUmZscpNjPvM5tm0+pLHyrPTchWvWCQIm9yi2vVzg/f0rbfdm0sN38092CCVQHZl3TFyRjzDKovlG6nK9SGO6vsliEtVHFV2M0LwGLgB8LdfDHpzVkM0dV23L7fXzOwzoI/JQuGrzGSfh35Vxqf/rdP2nQOJ0II8+CtCdohrjD7RXwjYt3IrOTjO1MtEQpSzmsvZ9NOQMdBOUvPbpTwY32tWClDClW3Y7t3EWOKwE3WvBfoep9xQC2bNrg5ICARQSDNA3pq4JhaZxf55ZjWbe+w== X-Forefront-Antispam-Report: CIP:195.60.68.100;CTRY:SE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.axis.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(346002)(376002)(136003)(39860400002)(396003)(230922051799003)(451199024)(82310400011)(1800799009)(64100799003)(186009)(36840700001)(46966006)(40470700004)(2906002)(110136005)(40480700001)(86362001)(41300700001)(66899024)(4326008)(8676002)(70206006)(70586007)(40460700003)(5660300002)(44832011)(36756003)(316002)(54906003)(8936002)(42186006)(82740400003)(2616005)(356005)(107886003)(26005)(81166007)(83380400001)(336012)(6266002)(6666004)(36860700001)(47076005)(426003)(478600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: axis.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Oct 2023 14:47:43.2988 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b48aaed4-dcfe-49a5-3103-08dbd17b8444 X-MS-Exchange-CrossTenant-Id: 78703d3c-b907-432f-b066-88f7af9ca3af X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=78703d3c-b907-432f-b066-88f7af9ca3af;Ip=[195.60.68.100];Helo=[mail.axis.com] X-MS-Exchange-CrossTenant-AuthSource: AM1PEPF000252DC.eurprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR02MB9692 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 20 Oct 2023 07:48:07 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780291154654561569 X-GMAIL-MSGID: 1780291154654561569 |
Series |
um: time-travel: fix time going backwards
|
|
Commit Message
Vincent Whitchurch
Oct. 20, 2023, 2:47 p.m. UTC
In basic time travel mode, I sometimes see "time goes backwards" panics
like the one below:
Kernel panic: time-travel: time goes backwards 161689340000492 -> 161689339869814
Call Trace:
panic+0x1a1/0x3d7
time_travel_update_time.cold+0xe9/0x133
timer_read+0xc1/0x100
ktime_get+0x10c/0x200
copy_process+0x1899/0x2230
kernel_clone+0x57/0x7a0
kernel_thread+0x4a/0x50
kthreadd+0x116/0x190
The problem is a race between time_travel_handle_real_alarm() and
timer_read(). time_travel_handle_real_alarm() changes the time after
time_read() reads the current time but before time_travel_update_time()
has had a chance to add the end event.
Fix this by doing the time read and event add atomically with respect to
time_travel_handle_real_alarm().
Signed-off-by: Vincent Whitchurch <vincent.whitchurch@axis.com>
---
arch/um/kernel/time.c | 48 ++++++++++++++++++++++++++++++++++--------------
1 file changed, 34 insertions(+), 14 deletions(-)
---
base-commit: 58720809f52779dc0f08e53e54b014209d13eebb
change-id: 20231020-uml-time-backwards-552c81aedd23
Best regards,
Comments
On Fri, 2023-10-20 at 16:47 +0200, Vincent Whitchurch wrote: > In basic time travel mode, I sometimes see "time goes backwards" panics > like the one below: > > Kernel panic: time-travel: time goes backwards 161689340000492 -> 161689339869814 > Call Trace: > panic+0x1a1/0x3d7 > time_travel_update_time.cold+0xe9/0x133 > timer_read+0xc1/0x100 > ktime_get+0x10c/0x200 > copy_process+0x1899/0x2230 > kernel_clone+0x57/0x7a0 > kernel_thread+0x4a/0x50 > kthreadd+0x116/0x190 > > The problem is a race between time_travel_handle_real_alarm() and > timer_read(). time_travel_handle_real_alarm() changes the time after > time_read() reads the current time but before time_travel_update_time() > has had a chance to add the end event. > > Fix this by doing the time read and event add atomically with respect to > time_travel_handle_real_alarm(). Further testing resulted in hitting the BUG_ON(time_travel_time != e->time) so looks like this needs some more work. BUG: failure at arch/um/kernel/time.c:409/time_travel_update_to_event()! Kernel panic - not syncing: BUG! CPU: 0 PID: 1 Comm: swapper Not tainted 6.5.0+ #13 Stack: 624db908 60a06c60 41b58ab3 60ae2398 6003fb90 10000c1e577c 41b58ab3 60b419ae 607f0dc0 00000000 00000000 6005b270 Call Trace: [<607fad5d>] show_stack.cold+0xc0/0x149 [<60841364>] dump_stack_lvl+0x75/0x94 [<6084139d>] dump_stack+0x1a/0x1c [<607fca1d>] panic+0x27e/0x490 [<607fb093>] time_travel_update_to_event.cold+0x89/0x18b [<60041317>] time_travel_forward_time.constprop.0+0xf7/0x160 [<600414f1>] timer_read+0x171/0x1b0 [<60140652>] random_get_entropy_fallback+0x42/0x60 [<60545943>] add_device_randomness+0x73/0xf0 [<6003a685>] do_one_initcall+0x145/0x3b0 [<60002598>] 0x60002598 [<60843ac5>] kernel_init+0x4a/0x195 [<6003d111>] new_thread_handler+0x141/0x1a0
On Mon, 2023-10-23 at 07:08 +0000, Vincent Whitchurch wrote: > On Fri, 2023-10-20 at 16:47 +0200, Vincent Whitchurch wrote: > > In basic time travel mode, I sometimes see "time goes backwards" panics > > like the one below: > > > > Kernel panic: time-travel: time goes backwards 161689340000492 -> 161689339869814 Ouch. > > Call Trace: > > panic+0x1a1/0x3d7 > > time_travel_update_time.cold+0xe9/0x133 > > timer_read+0xc1/0x100 > > ktime_get+0x10c/0x200 > > copy_process+0x1899/0x2230 > > kernel_clone+0x57/0x7a0 > > kernel_thread+0x4a/0x50 > > kthreadd+0x116/0x190 > > > > The problem is a race between time_travel_handle_real_alarm() and > > timer_read(). time_travel_handle_real_alarm() changes the time after > > time_read() reads the current time but before time_travel_update_time() > > has had a chance to add the end event. > > > > Fix this by doing the time read and event add atomically with respect to > > time_travel_handle_real_alarm(). > > Further testing resulted in hitting the BUG_ON(time_travel_time != > e->time) so looks like this needs some more work. > Yeah this is a tricky area, I fought with it for quite a while too, seems we're not done yet ;-) We mostly use time-travel=ext mode these days, so our system may not be as susceptible to it? But not sure, in some cases it runs with just a single instance, and that should be pretty much the same due to the free-until information. Do you have a specific workload that tends to reproduce this? johannes
On Mon, 2023-10-23 at 09:33 +0200, Johannes Berg wrote:
> Do you have a specific workload that tends to reproduce this?
I've been seeing it when running roadtest, but it's easily reproducible
without that by using the attached config and the following program as
init.
cp repro.config .config
make ARCH=um olddefconfig all
gcc -Wall -static -o repro repro.c
./linux time-travel init=$PWD/repro rootfstype=hostfs
With the above commands I usually see the panic in a few seconds. This
is on an unmodified v6.6-rc7.
----8<-------
#include <time.h>
#include <pthread.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
int main(void)
{
if (fork() == 0) {
while (1) {
nanosleep(&(struct timespec){.tv_nsec = 330 * 1000}, NULL);
}
return 0;
}
while (1) {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
nanosleep(&(struct timespec){.tv_nsec = 22 * 1000}, NULL);
}
return 0;
}
# CONFIG_LOCALVERSION_AUTO is not set
CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y
CONFIG_LOG_BUF_SHIFT=18
CONFIG_EXPERT=y
CONFIG_HOSTFS=y
CONFIG_MAGIC_SYSRQ=y
CONFIG_UML_TIME_TRAVEL_SUPPORT=y
CONFIG_SSL=y
CONFIG_NULL_CHAN=y
CONFIG_PORT_CHAN=y
CONFIG_PTY_CHAN=y
CONFIG_TTY_CHAN=y
CONFIG_XTERM_CHAN=y
CONFIG_CON_CHAN="pts"
CONFIG_SSL_CHAN="pts"
CONFIG_VIRTIO_UML=y
CONFIG_UML_PCI_OVER_VIRTIO=y
CONFIG_UML_PCI_OVER_VIRTIO_DEVICE_ID=1234
CONFIG_GCOV_KERNEL=y
CONFIG_MODULES=y
CONFIG_MODULE_UNLOAD=y
CONFIG_BINFMT_MISC=m
# CONFIG_COMPACTION is not set
CONFIG_NET=y
CONFIG_UNIX=y
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
CONFIG_OF=y
# CONFIG_INPUT is not set
CONFIG_LEGACY_PTY_COUNT=32
CONFIG_SERIAL_SC16IS7XX=m
CONFIG_GOLDFISH_TTY=m
CONFIG_SERIAL_DEV_BUS=y
CONFIG_UML_RANDOM=y
# CONFIG_I2C_COMPAT is not set
CONFIG_I2C_CHARDEV=y
CONFIG_I2C_VIRTIO=y
CONFIG_I2C_STUB=m
CONFIG_SPI=y
CONFIG_SPI_SC18IS602=y
CONFIG_SPI_MUX=y
CONFIG_PINCTRL=y
CONFIG_GPIOLIB=y
CONFIG_GPIO_SYSFS=y
CONFIG_GPIO_GENERIC_PLATFORM=m
CONFIG_GPIO_MOCKUP=y
CONFIG_GPIO_VIRTIO=y
CONFIG_POWER_SUPPLY=y
CONFIG_CHARGER_BQ256XX=m
CONFIG_PMBUS=y
CONFIG_SENSORS_LTC2978=m
CONFIG_SENSORS_LTC2978_REGULATOR=y
CONFIG_SENSORS_PWM_FAN=m
CONFIG_SENSORS_TMP401=m
CONFIG_REGULATOR=y
CONFIG_REGULATOR_DEBUG=y
CONFIG_REGULATOR_FIXED_VOLTAGE=y
CONFIG_REGULATOR_VIRTUAL_CONSUMER=m
CONFIG_REGULATOR_GPIO=m
CONFIG_REGULATOR_TPS6286X=m
CONFIG_REGULATOR_TPS6287X=m
CONFIG_DRM=y
CONFIG_TINYDRM_ILI9341=m
CONFIG_NEW_LEDS=y
CONFIG_LEDS_CLASS=y
CONFIG_LEDS_GPIO=y
CONFIG_LEDS_TRIGGERS=y
CONFIG_LEDS_TRIGGER_HEARTBEAT=y
CONFIG_RTC_CLASS=y
# CONFIG_RTC_HCTOSYS is not set
# CONFIG_RTC_SYSTOHC is not set
CONFIG_RTC_DEBUG=y
CONFIG_RTC_DRV_PCF8523=m
CONFIG_RTC_DRV_PCF8563=m
CONFIG_GOLDFISH=y
CONFIG_COMMON_CLK=y
CONFIG_COMMON_CLK_SI5351=m
CONFIG_IIO=y
CONFIG_IIO_BUFFER_CB=m
CONFIG_IIO_SW_TRIGGER=y
CONFIG_MCP320X=m
CONFIG_TI_ADC081C=m
CONFIG_TI_ADC084S021=m
CONFIG_TI_ADS7924=m
CONFIG_PMS7003=m
CONFIG_OPT3001=m
CONFIG_OPT4001=m
CONFIG_VCNL4000=m
CONFIG_IIO_HRTIMER_TRIGGER=y
CONFIG_IIO_SYSFS_TRIGGER=y
CONFIG_IRSD200=m
CONFIG_PWM=y
CONFIG_PWM_PCA9685=m
CONFIG_MUX_GPIO=y
CONFIG_QUOTA=y
CONFIG_PROC_KCORE=y
CONFIG_TMPFS=y
CONFIG_NLS=y
CONFIG_CRYPTO=y
CONFIG_CRYPTO_CRC32C=y
CONFIG_CRYPTO_JITTERENTROPY=y
CONFIG_CRC16=y
CONFIG_PRINTK_TIME=y
CONFIG_PRINTK_CALLER=y
CONFIG_DYNAMIC_DEBUG=y
CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y
CONFIG_GDB_SCRIPTS=y
CONFIG_FRAME_WARN=1024
CONFIG_READABLE_ASM=y
CONFIG_DEBUG_FS=y
CONFIG_UBSAN=y
CONFIG_PAGE_EXTENSION=y
CONFIG_DEBUG_OBJECTS=y
CONFIG_DEBUG_OBJECTS_FREE=y
CONFIG_DEBUG_OBJECTS_TIMERS=y
CONFIG_DEBUG_OBJECTS_WORK=y
CONFIG_KASAN=y
CONFIG_PROVE_LOCKING=y
CONFIG_ENABLE_DEFAULT_TRACERS=y
CONFIG_FAULT_INJECTION=y
CONFIG_FAILSLAB=y
CONFIG_FAULT_INJECTION_DEBUG_FS=y
CONFIG_FAULT_INJECTION_STACKTRACE_FILTER=y
On Wed, 2023-10-25 at 11:55 +0000, Vincent Whitchurch wrote: > On Mon, 2023-10-23 at 09:33 +0200, Johannes Berg wrote: > > Do you have a specific workload that tends to reproduce this? > > I've been seeing it when running roadtest, but it's easily reproducible > without that by using the attached config and the following program as > init. > > cp repro.config .config > make ARCH=um olddefconfig all > gcc -Wall -static -o repro repro.c > ./linux time-travel init=$PWD/repro rootfstype=hostfs > > With the above commands I usually see the panic in a few seconds. This > is on an unmodified v6.6-rc7. > Yes, I can reproduce it with your test, thanks. I'm on 6.4-rc still for $reasons (6.5 we skipped during vacations, and 6.6 EEVDF scheduler broke everything for hwsim tests in hostap), but this code didn't really change anyway. I'll poke at this. (And I'm still amazed that anyone other than me even uses this stuff :P) johannes
On Wed, 2023-10-25 at 21:51 +0200, Johannes Berg wrote: > On Wed, 2023-10-25 at 11:55 +0000, Vincent Whitchurch wrote: > > On Mon, 2023-10-23 at 09:33 +0200, Johannes Berg wrote: > > > Do you have a specific workload that tends to reproduce this? > > > > I've been seeing it when running roadtest, but it's easily reproducible > > without that by using the attached config and the following program as > > init. > > > > cp repro.config .config > > make ARCH=um olddefconfig all > > gcc -Wall -static -o repro repro.c > > ./linux time-travel init=$PWD/repro rootfstype=hostfs Ohhh. Pure "time-travel" is actually something I hardly think about these days, we mostly use time-travel=inf-cpu (or =ext). That makes sense, here you actually *can* get interrupted. I'll need to dig into what happens though. johannes
On Wed, 2023-10-25 at 22:02 +0200, Johannes Berg wrote: > On Wed, 2023-10-25 at 21:51 +0200, Johannes Berg wrote: > > On Wed, 2023-10-25 at 11:55 +0000, Vincent Whitchurch wrote: > > > On Mon, 2023-10-23 at 09:33 +0200, Johannes Berg wrote: > > > > Do you have a specific workload that tends to reproduce this? > > > > > > I've been seeing it when running roadtest, but it's easily reproducible > > > without that by using the attached config and the following program as > > > init. > > > > > > cp repro.config .config > > > make ARCH=um olddefconfig all > > > gcc -Wall -static -o repro repro.c > > > ./linux time-travel init=$PWD/repro rootfstype=hostfs > > Ohhh. > > Pure "time-travel" is actually something I hardly think about these > days, we mostly use time-travel=inf-cpu (or =ext). > > That makes sense, here you actually *can* get interrupted. I'll need to > dig into what happens though. I just sent a patch, please take a look. It does seem to fix it - at least I got bored of waiting after running your test program for a few minutes :) johannes
diff --git a/arch/um/kernel/time.c b/arch/um/kernel/time.c index fddd1dec27e6..38a94dd41b8f 100644 --- a/arch/um/kernel/time.c +++ b/arch/um/kernel/time.c @@ -392,17 +392,11 @@ bool time_travel_del_event(struct time_travel_event *e) return true; } -static void time_travel_update_time(unsigned long long next, bool idle) +static void time_travel_update_to_event(struct time_travel_event *ne, bool idle) { - struct time_travel_event ne = { - .onstack = true, - }; struct time_travel_event *e; bool finished = idle; - /* add it without a handler - we deal with that specifically below */ - __time_travel_add_event(&ne, next); - do { e = time_travel_first_event(); @@ -414,7 +408,7 @@ static void time_travel_update_time(unsigned long long next, bool idle) BUG_ON(!time_travel_del_event(e)); BUG_ON(time_travel_time != e->time); - if (e == &ne) { + if (e == ne) { finished = true; } else { if (e->onstack) @@ -427,14 +421,38 @@ static void time_travel_update_time(unsigned long long next, bool idle) e = time_travel_first_event(); if (e) time_travel_ext_update_request(e->time); - } while (ne.pending && !finished); + } while (ne->pending && !finished); + + time_travel_del_event(ne); +} - time_travel_del_event(&ne); +static void time_travel_update_time(unsigned long long next, bool idle) +{ + struct time_travel_event ne = { + .onstack = true, + }; + + __time_travel_add_event(&ne, next); + time_travel_update_to_event(&ne, idle); +} + +static void time_travel_forward_time(unsigned long nsec, bool idle) +{ + struct time_travel_event ne = { + .onstack = true, + }; + unsigned long flags; + + local_irq_save(flags); + __time_travel_add_event(&ne, time_travel_time + nsec); + local_irq_restore(flags); + + time_travel_update_to_event(&ne, idle); } void time_travel_ndelay(unsigned long nsec) { - time_travel_update_time(time_travel_time + nsec, false); + time_travel_forward_time(nsec, false); } EXPORT_SYMBOL(time_travel_ndelay); @@ -572,6 +590,10 @@ static inline void time_travel_update_time(unsigned long long ns, bool retearly) { } +static void time_travel_forward_time(unsigned long nsec, bool idle) +{ +} + static inline void time_travel_handle_real_alarm(void) { } @@ -720,9 +742,7 @@ static u64 timer_read(struct clocksource *cs) */ if (!irqs_disabled() && !in_interrupt() && !in_softirq() && !time_travel_ext_waiting) - time_travel_update_time(time_travel_time + - TIMER_MULTIPLIER, - false); + time_travel_forward_time(TIMER_MULTIPLIER, false); return time_travel_time / TIMER_MULTIPLIER; }