Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp6897608rdb; Fri, 15 Dec 2023 11:09:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEr5ZCImS5J/X/aZTrPFJg7zFtQBy4xFQBXuZoWnlKuIKv510U8wo1QNqlnHEcOQZssNfK X-Received: by 2002:ac8:5bc1:0:b0:425:8b0b:c626 with SMTP id b1-20020ac85bc1000000b004258b0bc626mr12471090qtb.104.1702667379475; Fri, 15 Dec 2023 11:09:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702667379; cv=none; d=google.com; s=arc-20160816; b=e1eayIuWJC3tI39higVF3i4bdFkJDd+lxTvblODdfw7SEIZleawhbWdkagRNYruTj0 wzLdV41Z53XbkufgKVMpJjt95VQDvpa6gRKTyISzDKkCf7X8THVyH/F3AdPKHr00eudX DU24XSN17KeP6Bf8c+JwUCml3qluBAiua7uvEL8HW8MuFfCYXPCtYABhj0RFBK9PwRmc hQLP7AbOOAsa93WDK3/5Yep9hVmgS1fz4nbPKnoWY5uKOA45u8NvgdYe5Wx+Ja/tvvQE NZSV0G4szZWzqi7MGnAGLE7MTYi23OVvYGyrmt4kg+NXgqhaY9+2JTeMl4r9zmWRQUEQ aOiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=XdoNIFgiKKjltF4d35fDvG6l9Px6HFW2fOBXd8f2UN8=; fh=+QXSg97ZBTBIXRgxc5cKtycoqOh0S4AlufJO5gvvJ0s=; b=hCHvmwmiK39n/YFUtC3sU2nfJ2nHvFuMjAYRTjls9UKuMvec87kThes23iBLcm4atg 5frDC4DP6lp3ktmlA3J79GMuhfY9rRo4RrdRzZ0FBVCzeB0RCIqsyAt3kN4oUYvCaC7k 8rQAx07GP3qic3C/bw2YwXh0UYl3mmxOjybos6s1npWsI+fMuZ2Knxz0xIi+0LNFHgb3 0P8FJfiC375A82JR/PhkMcmsaG3AzcT3tbTQZOgw5dDt0LkBfvUVPZ9pvcZW107SRYFe X6BeOjGDP8CYxIHv5vRbubOboEPhXs3LJlJWejl2sHlcKcrpI4seccUh908SzZ1a8gxc UxKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3wI1NN5+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-1552-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1552-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id fb8-20020a05622a480800b004237f54a7f2si20604128qtb.191.2023.12.15.11.09.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Dec 2023 11:09:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-1552-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=3wI1NN5+; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-1552-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-1552-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 9C0051C241D6 for ; Fri, 15 Dec 2023 19:09:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 04D543FE45; Fri, 15 Dec 2023 19:09:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="3wI1NN5+"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="KkijHHHK" X-Original-To: linux-kernel@vger.kernel.org Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D9E973FB11 for ; Fri, 15 Dec 2023 19:09:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1702667367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XdoNIFgiKKjltF4d35fDvG6l9Px6HFW2fOBXd8f2UN8=; b=3wI1NN5+yNmVu/AqvyeGuaWppDOdo9WTn+Jgs5VU9aH7NVHOqe3Uz6A2b/pPGygllUbwYI H9KXBvtmZbc2FQX7f55UNaQVoXO89KXWzTfLc/y5ju96zCEWSbSwvaESDRW6LEhtEPRU3q I1wmjnohlWtsB/z7KBTthUGXi7vLPzke+ea/KWMGPin4yEX0Z+Yf8gQd48lzUGLdjdxQaS smCid615OtOT2SWVFOp/WVA3y7d7cUVRCaUCPD5hozPniN+k5343VSTZISj6xgXJAEa8IW 8lubTGpaQexBEJqFhYL7F1SdNusOLJDXIxY5r1ji81DrNafj9kdz+e8cRIY9bA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1702667367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XdoNIFgiKKjltF4d35fDvG6l9Px6HFW2fOBXd8f2UN8=; b=KkijHHHKwrD5Nqa0XioXOX9S/s6w3dr6sFH2uCNTRuln6fZml1iHZThYDuqNiZ8lMXQK0b 24dc6Ji3xm+brbBQ== To: Sven Schnelle , Peter Zijlstra , Andy Lutomirski Cc: linux-kernel@vger.kernel.org, Heiko Carstens Subject: Re: [PATCH 1/3] entry: move exit to usermode functions to header file In-Reply-To: <20231205133015.752543-2-svens@linux.ibm.com> References: <20231205133015.752543-1-svens@linux.ibm.com> <20231205133015.752543-2-svens@linux.ibm.com> Date: Fri, 15 Dec 2023 20:09:27 +0100 Message-ID: <87r0jnmgew.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Tue, Dec 05 2023 at 14:30, Sven Schnelle wrote: > +/** > + * exit_to_user_mode_loop - do any pending work before leaving to user space > + */ > +static __always_inline unsigned long exit_to_user_mode_loop(struct pt_regs *regs, > + unsigned long ti_work) > +{ > + /* > + * Before returning to user space ensure that all pending work > + * items have been completed. > + */ > + while (ti_work & EXIT_TO_USER_MODE_WORK) { > + > + local_irq_enable_exit_to_user(ti_work); > + > + if (ti_work & _TIF_NEED_RESCHED) > + schedule(); > + > + if (ti_work & _TIF_UPROBE) > + uprobe_notify_resume(regs); > + > + if (ti_work & _TIF_PATCH_PENDING) > + klp_update_patch_state(current); > + > + if (ti_work & (_TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)) > + arch_do_signal_or_restart(regs); > + > + if (ti_work & _TIF_NOTIFY_RESUME) > + resume_user_mode_work(regs); > + > + /* Architecture specific TIF work */ > + arch_exit_to_user_mode_work(regs, ti_work); > + > + /* > + * Disable interrupts and reevaluate the work flags as they > + * might have changed while interrupts and preemption was > + * enabled above. > + */ > + local_irq_disable_exit_to_user(); > + > + /* Check if any of the above work has queued a deferred wakeup */ > + tick_nohz_user_enter_prepare(); > + > + ti_work = read_thread_flags(); > + } > + > + /* Return the latest work state for arch_exit_to_user_mode() */ > + return ti_work; > +} I'm not really sure about this part. exit_to_user_mode_loop() is the slowpath when a TIF work flag is set. I can see the benefit on the fastpath functions which are way smaller. Thanks, tglx