From patchwork Fri Aug 30 15:38:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1979094 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=VDhLrRPI; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=bT5s4Shh; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=pVg3G2tg; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WwMlH1bBYz1ydy for ; Sat, 31 Aug 2024 01:39:23 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=OjRIodtRv7xl6NM9Aiu0uvHXUVQZiYl6aAIuCQA1KaA=; b=VDhLrRPITZu/uzl9aA4Aw3tuct bQIIy4RTkQgRJEzQFQDl0pWzz1uh9LJXmfCaBgVqrCwIH0T/g2N1pPQXu/6TTSWedw06RGsl2u2+l +B3Yx3mYnjyPQ3EPySLp63mw023Syj/rqxZNAhF56KWM3mGJl8s2Y/wtW4KAjK3sZxEOGDDkXPyVG E/zo9pLdcX8JmVPIee+YOhwnwtdxIERGFh3vPqnrFWShh/eSS1+xOFenCB1V+WHsoRR1aJbhYaTkc diqfFglImL0SA8esw+0uKQpAQSuEE1u29Syep44FNrdFdc/dMZLihNY2LQ2rRz86EsPymJaK53V4p ZDI+2S/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sk3ib-00000006quJ-0tNn; Fri, 30 Aug 2024 15:39:21 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sk3iZ-00000006qts-34pz for linux-um@bombadil.infradead.org; Fri, 30 Aug 2024 15:39:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:In-Reply-To:References; bh=OjRIodtRv7xl6NM9Aiu0uvHXUVQZiYl6aAIuCQA1KaA=; b=bT5s4ShhA3ZqpP3uV1xw6DzYzM cRQS1hwojNSQPLVOQAXxvr6SZbpz112srt8vnTVua1LuZRiY/zWOINgXZZ82JTu2qHGzMPdJnkDmf p5ILkWCb/iYsG/b8DJ2QMb9I5llQhEdeNpj284jKldQT/8GSbUgbNn1rspk7QiB1Ml5WdkCaY++Ku 01Mizi1sOJBq/9gMAnClbn+SsUiQyyFAHPK4VexX03w05RBNEjDXb2CUU/88srX+ODfMl49uss6ye trBTaIQ7hDj3ejQ/MOSKGle4tEAHL4ky3tUreQraNGcDJT+l2mvtJDIKlNvDqWKiQEzA/soc5ehAm 9nlzPSpg==; Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sk3iU-0000000Bi7j-0536 for linux-um@lists.infradead.org; Fri, 30 Aug 2024 15:39:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-To:Resent-Cc: Resent-Message-ID:In-Reply-To:References; bh=OjRIodtRv7xl6NM9Aiu0uvHXUVQZiYl6aAIuCQA1KaA=; t=1725032350; x=1726241950; b=pVg3G2tg78eVOiz4QM+uPgSQw+jD3tr6BcfWmYImh7bVlTvHBcMO6Pdz70mNmryD102zFO/JkPO vomUoDvQR3y2UCwUrnWwN1ms3hm77/GQmVnTr/5PEpkPvJGxBCsiKCnlxzlaDt99lHLIGDDPNT8s8 tAuBvtuBS46DOjik1H9KpZOvTqULP540QmpBP4JaPj9pMrGi1A6qxuvI3L/lvfvbVI/oRJAL6iVF0 yxdLJoL/VMxWh6vZvOysSm/Q2IrBMfOt8OU24QrjTqiyoZ2ir4HRYA3taQFf5vov/3b5Yb28l65hm Iyoq3ACXk8A5lW0r48CSOTVFjWAuO53VsuFg==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1sk3iM-0000000Bhhe-37qz; Fri, 30 Aug 2024 17:39:07 +0200 From: Benjamin Berg To: linux-um@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH] um: add RCU syscall hack for time-travel Date: Fri, 30 Aug 2024 17:38:25 +0200 Message-ID: <20240830153825.1466691-1-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240830_163914_439997_50DB0783 X-CRM114-Status: UNSURE ( 9.44 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Benjamin Berg In time-travel mode userspace can do a lot of work without any time passing. Unfortunately, this can result in OOM situations as the RCU core code will never be run. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 T_SCC_BODY_TEXT_LINE No description available. X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Benjamin Berg In time-travel mode userspace can do a lot of work without any time passing. Unfortunately, this can result in OOM situations as the RCU core code will never be run. Work around that by kicking the RCU using rcu_sched_clock_irq. So behave to the RCU code as if a clock tick happened every syscall. Signed-off-by: Benjamin Berg --- This patch is on top of "um: fix time-travel syscall scheduling hack" --- arch/um/kernel/skas/syscall.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/um/kernel/skas/syscall.c b/arch/um/kernel/skas/syscall.c index b09e85279d2b..4b4ab8bf8a0c 100644 --- a/arch/um/kernel/skas/syscall.c +++ b/arch/um/kernel/skas/syscall.c @@ -19,6 +19,21 @@ void handle_syscall(struct uml_pt_regs *r) struct pt_regs *regs = container_of(r, struct pt_regs, regs); int syscall; + /* + * This is a "bit" of a hack. But in time-travel mode userspace can do + * a lot of work without any time passing. Unfortunately, this can + * result in OOM situations as the RCU core code will never be run. + * + * Work around that by kicking the RCU using rcu_sched_clock_irq. So + * behave to the RCU code as if a clock tick happened every syscall. + */ + if (time_travel_mode == TT_MODE_INFCPU || + time_travel_mode == TT_MODE_EXTERNAL) { + local_irq_disable(); + rcu_sched_clock_irq(1); + local_irq_enable(); + } + /* Initialize the syscall number and default return value. */ UPT_SYSCALL_NR(r) = PT_SYSCALL_NR(r->gp); PT_REGS_SET_SYSCALL_RETURN(regs, -ENOSYS);