Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp6782707rwb; Wed, 10 Aug 2022 00:38:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR60E7rhX+HynqvJuwxho2+1xJhYLodm40QJWYUjn9Av6XQl+flFz4teC44NUFlrYBfTn8zc X-Received: by 2002:a05:6402:2756:b0:43b:fda4:abc6 with SMTP id z22-20020a056402275600b0043bfda4abc6mr24440401edd.274.1660117082535; Wed, 10 Aug 2022 00:38:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660117082; cv=none; d=google.com; s=arc-20160816; b=ahOPx079Uwt1xoxBnrzdy1ojWlWrVIww4J5oUdQRhnlOmADTT34Yy1i7Z7WeSVz7xL uFe+cZzm1v6gIpN8fngfCbZU5h7GqLM47xofBM+62xq423MnaF6eazWOh4KDL1dMw6Y9 8X/faDTIiBPFNZNuZveJ0y9/DxppsU7SOvNfBbelJCZOUrLJsU08sfrJ8TPLVuAY9zci tAYTSQi63LwT7WSJOW20c5LC8Ng8VYkYLPwHETb/tm4QzeEKy9GTWHoybZ8ENxxtDNIm gWFsqWoRzw4J44s9qqUy/XGeKNxMptXAzi5kJmMbP2BM5zVKN/1n/NJ7Rr956slS4cFe 3DUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=ffLIQVAGIVPV6ZV8JBI4al5/eLbBn8Xd04Qi2APVWdk=; b=JD6mPi4A9xVgSZcvUamgNMDPK0pr3tlwKa7JE0gXNh2RLTsGKU4v3e0SOvtYIfic2u K+oLTluptvMATOcUUft2ZOYBDba/HTLCylBIs0xr5+SRz8XDuYhOVqItOxo6AYyVZTUK EG1aKCuJ2UVwoR09l+dopPhZdxQGhzS0PUC4bJIR9LZL0z05chU2YtezNEJLP/RB0Yjz kDeXE3B9U2K310Oj5jHeWRUUEjLcv/7+Avbrh27XY1hXn8+Ei7sSB512A+3yDBTJFJnF iSjCKzYt9rxKD84hvRIT6qNBflC2PTvYQLLFVoD1qVNEAFWcObZniq653vbxGngIdpHt jHPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gQsDaQUU; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss28-20020a170907c01c00b00730cda94bbasi2974961ejc.952.2022.08.10.00.37.37; Wed, 10 Aug 2022 00:38:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=gQsDaQUU; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231232AbiHJHZz (ORCPT + 99 others); Wed, 10 Aug 2022 03:25:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230390AbiHJHZx (ORCPT ); Wed, 10 Aug 2022 03:25:53 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B784193D2 for ; Wed, 10 Aug 2022 00:25:51 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1660116349; 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=ffLIQVAGIVPV6ZV8JBI4al5/eLbBn8Xd04Qi2APVWdk=; b=gQsDaQUUU4pAyx9RmsXuibIavf9tnZTYd9OZYRVa5gVj/fE1ONDX93WDFolM8syVh7+u4S wDeJMoLB3yFhknkW+BX3i88X22r/Efn6eDxlZV6Ix/sLigonRLuMmyg72V3u7Bh/L6HFR6 mDgUIlQlrDXv/WKj1YpFfPPIdFMbEyWH6TjkFl0oVM+JcCLD35LkEzV2jrx6KV7/MOY8fp FwAfC8P2hIRVx8BO5UUWSmjc61iQJW25J7JLkZZkt2g0G0tPUtzVvFIQdZ2EX/u2BOiJQO 3DsaGA6fVNz93UXnRd9NXmyxqZiFy++lnpyy0fDfbj4uykhKYhaZ1W0jHbzajA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1660116349; 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=ffLIQVAGIVPV6ZV8JBI4al5/eLbBn8Xd04Qi2APVWdk=; b=srsQFUyf59Y1aacJivQ6q93A9cgX0D73ThYUA4+RDUoDYRGXbojmpgC2hTUKb3BKypidvL O16/JJmPnCfHMwAA== To: Borislav Petkov , ira.weiny@intel.com Cc: Rik van Riel , Dave Hansen , Dave Hansen , x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Frederic Weisbecker , Juergen Gross , Mark Rutland , Andrew Cooper Subject: Re: [RFC PATCH 1/5] entry: Pass pt_regs to irqentry_exit_cond_resched() In-Reply-To: <87fsi5qa49.ffs@tglx> References: <20220805173009.3128098-1-ira.weiny@intel.com> <20220805173009.3128098-2-ira.weiny@intel.com> <87fsi5qa49.ffs@tglx> Date: Wed, 10 Aug 2022 09:25:48 +0200 Message-ID: <87a68cr24j.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 10 2022 at 01:18, Thomas Gleixner wrote: > Both clearly demonstrate how well tested this XEN_PV muck is which means > we should just delete it. > > Anyway. This wants the fix below. which is not sufficient. If CONFIG_PREEMPT_DYNAMIC is set then CONFIG_PREEMPTION is set too, which makes the preemtible hypercall magic a complete NOP. So if the dynamic call is disabled, then such a several seconds (sic!) hypercall cannot be preempted at all. Something like the below then. Oh well... Thanks, tglx --- --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -253,7 +253,8 @@ SYSCALL_DEFINE0(ni_syscall) } #ifdef CONFIG_XEN_PV -#ifndef CONFIG_PREEMPTION + +#if !defined(CONFIG_PREEMPTION) || defined(CONFIG_PREEMPT_DYNAMIC) /* * Some hypercalls issued by the toolstack can take many 10s of * seconds. Allow tasks running hypercalls via the privcmd driver to @@ -283,9 +284,18 @@ static __always_inline void restore_inhc { __this_cpu_write(xen_in_preemptible_hcall, inhcall); } + +static __always_inline void xenpv_irqentry_exit_cond_resched(void) +{ + instrumentation_begin(); + raw_irqentry_exit_cond_resched(); + trace_hardirqs_on(); + instrumentation_end(); +} #else static __always_inline bool get_and_clear_inhcall(void) { return false; } static __always_inline void restore_inhcall(bool inhcall) { } +static __always_inline void xenpv_irqentry_exit_cond_resched(void) { } #endif static void __xen_pv_evtchn_do_upcall(struct pt_regs *regs) @@ -306,11 +316,11 @@ static void __xen_pv_evtchn_do_upcall(st instrumentation_begin(); run_sysvec_on_irqstack_cond(__xen_pv_evtchn_do_upcall, regs); + instrumentation_end(); inhcall = get_and_clear_inhcall(); if (inhcall && !WARN_ON_ONCE(state.exit_rcu)) { - irqentry_exit_cond_resched(); - instrumentation_end(); + xenpv_irqentry_exit_cond_resched(); restore_inhcall(inhcall); } else { instrumentation_end(); --- a/include/linux/entry-common.h +++ b/include/linux/entry-common.h @@ -416,6 +416,7 @@ irqentry_state_t noinstr irqentry_enter( * Conditional reschedule with additional sanity checks. */ void raw_irqentry_exit_cond_resched(void); + #ifdef CONFIG_PREEMPT_DYNAMIC #if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL) #define irqentry_exit_cond_resched_dynamic_enabled raw_irqentry_exit_cond_resched --- a/include/xen/xen-ops.h +++ b/include/xen/xen-ops.h @@ -194,7 +194,7 @@ bool xen_running_on_version_or_later(uns void xen_efi_runtime_setup(void); -#if defined(CONFIG_XEN_PV) && !defined(CONFIG_PREEMPTION) +#if defined(CONFIG_XEN_PV) && (!defined(CONFIG_PREEMPTION) || defined(CONFIG_PREEMPT_DYNAMIC)) DECLARE_PER_CPU(bool, xen_in_preemptible_hcall); --- a/kernel/entry/common.c +++ b/kernel/entry/common.c @@ -385,6 +385,7 @@ void raw_irqentry_exit_cond_resched(void preempt_schedule_irq(); } } + #ifdef CONFIG_PREEMPT_DYNAMIC #if defined(CONFIG_HAVE_PREEMPT_DYNAMIC_CALL) DEFINE_STATIC_CALL(irqentry_exit_cond_resched, raw_irqentry_exit_cond_resched);