Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3499813pxu; Mon, 19 Oct 2020 13:47:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYMQ6WpeqbFn0eUeBcjy7TvSflBi6Wy2ElbiT4LZ0LBki0c8mbD4EHhlE/ub02Vu2Ud6KC X-Received: by 2002:aa7:d29a:: with SMTP id w26mr1643845edq.59.1603140420232; Mon, 19 Oct 2020 13:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603140420; cv=none; d=google.com; s=arc-20160816; b=IatJsSxEhUBh0I/i5pRX6llR1hz7XD9jYOBjwzIK6R9kiv6Y/f9xZ1v+1qRFgBehIX FHGkcqKdL5NfQBrXHqByojKO5u7zs9DPEoODGjw1lWKrLUFbW+mmldqcMBVVucKRHfe7 FAsEEcdvMykIVkSCZg/MH14pFPgRPh4Lam/nYv7PBj+tIKYAfjRyA6PqK1aRzju5kKCy pU3nZOPkQCAN/2z8xXizn6yO7+RnvPooddh8i3m3Kk++Ugz6ZHjXQTtivP9/4JJatG/1 MZ3h5bqlIkQHGBtHU8C6PZN4oUC0C6MGnfW3leZUqTsMV/06ZYltFl2t9LK7z20tgRIa KD5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=b1SeI7qZVWAXw+qjoCRA14w/TquADWFNjEWSL26DiHg=; b=PX0EHf9T9smrNFsK9uKOBqFMNzLFcOrLLIbn991dmmui3WN4ive1mzt1OxSsNurC5E ysV3joecsICK0X8ZpUPHI/Q3ryb5o1iboylAay3foJVPRS4MjItOMVWa28NKF0WcXH9+ cnJ2nVG1dSSoPMlen7jFT9v7vvFKvSnFweCkSq6W1Xm3tiDTm7VHTruhFlJfQ/ebWcoe 4bU5ZqSpu7Xh+FbfWrxESqAmn4lO1nJ8sfF64YvAWksL2XreRdY/v1UxpI8rwNAzb4IU IXKoEn41bauH6/OJBcjZxsrSi6uBPpeLyQWjQkvl7xd52sVG4epXr6KR+maCs2RivQqr b+wg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 16si530187edv.551.2020.10.19.13.46.38; Mon, 19 Oct 2020 13:47:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726454AbgJSFhv (ORCPT + 99 others); Mon, 19 Oct 2020 01:37:51 -0400 Received: from mga07.intel.com ([134.134.136.100]:36748 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725306AbgJSFhv (ORCPT ); Mon, 19 Oct 2020 01:37:51 -0400 IronPort-SDR: BCttGlvxXOv8IEMavzW7QCZDOzs1MO3AV/WwrIlbEaiYnCGxWVJREPVdnNqGF0ZSMH0+EnvcXG K6A+Vch2xQIA== X-IronPort-AV: E=McAfee;i="6000,8403,9778"; a="231162684" X-IronPort-AV: E=Sophos;i="5.77,393,1596524400"; d="scan'208";a="231162684" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2020 22:37:46 -0700 IronPort-SDR: RnOUFQmkYUDicpOlOT0tpOrIh/gyVBYXkd84kJDS4ikMZgrYuGPAp0+a9qjCzEuNsRXlsKxGfm 7ykQey1Ml/Rw== X-IronPort-AV: E=Sophos;i="5.77,393,1596524400"; d="scan'208";a="532493630" Received: from iweiny-desk2.sc.intel.com (HELO localhost) ([10.3.52.147]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Oct 2020 22:37:37 -0700 Date: Sun, 18 Oct 2020 22:37:36 -0700 From: Ira Weiny To: Thomas Gleixner Cc: Peter Zijlstra , Ingo Molnar , Borislav Petkov , Andy Lutomirski , x86@kernel.org, Dave Hansen , Dan Williams , Andrew Morton , Fenghua Yu , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH RFC V3 6/9] x86/entry: Pass irqentry_state_t by reference Message-ID: <20201019053639.GA3713473@iweiny-DESK2.sc.intel.com> References: <20201009194258.3207172-1-ira.weiny@intel.com> <20201009194258.3207172-7-ira.weiny@intel.com> <20201016114510.GO2611@hirez.programming.kicks-ass.net> <87lfg6tjnq.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87lfg6tjnq.fsf@nanos.tec.linutronix.de> User-Agent: Mutt/1.11.1 (2018-12-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 16, 2020 at 02:55:21PM +0200, Thomas Gleixner wrote: > On Fri, Oct 16 2020 at 13:45, Peter Zijlstra wrote: > > On Fri, Oct 09, 2020 at 12:42:55PM -0700, ira.weiny@intel.com wrote: > >> @@ -238,7 +236,7 @@ noinstr void idtentry_exit_nmi(struct pt_regs *regs, bool restore) > >> > >> rcu_nmi_exit(); > >> lockdep_hardirq_exit(); > >> - if (restore) > >> + if (irq_state->exit_rcu) > >> lockdep_hardirqs_on(CALLER_ADDR0); > >> __nmi_exit(); > >> } > > > > That's not nice.. The NMI path is different from the IRQ path and has a > > different variable. Yes, this works, but *groan*. > > > > Maybe union them if you want to avoid bloating the structure, but the > > above makes it really hard to read. > > Right, and also that nmi entry thing should not be in x86. Something > like the untested below as first cleanup. Ok, I see what Peter was talking about. I've added this patch to the series. > > Thanks, > > tglx > ---- > Subject: x86/entry: Move nmi entry/exit into common code > From: Thomas Gleixner > Date: Fri, 11 Sep 2020 10:09:56 +0200 > > Add blurb here. How about: To prepare for saving PKRS values across NMI's we lift the idtentry_[enter|exit]_nmi() to the common code. Rename them to irqentry_nmi_[enter|exit]() to reflect the new generic nature and store the state in the same irqentry_state_t structure as the other irqentry_*() functions. Finally, differentiate the state being stored between the NMI and IRQ path by adding 'lockdep' to irqentry_state_t. ? > > Signed-off-by: Thomas Gleixner > --- > arch/x86/entry/common.c | 34 ---------------------------------- > arch/x86/include/asm/idtentry.h | 3 --- > arch/x86/kernel/cpu/mce/core.c | 6 +++--- > arch/x86/kernel/nmi.c | 6 +++--- > arch/x86/kernel/traps.c | 13 +++++++------ > include/linux/entry-common.h | 20 ++++++++++++++++++++ > kernel/entry/common.c | 36 ++++++++++++++++++++++++++++++++++++ > 7 files changed, 69 insertions(+), 49 deletions(-) > [snip] > --- a/include/linux/entry-common.h > +++ b/include/linux/entry-common.h > @@ -343,6 +343,7 @@ void irqentry_exit_to_user_mode(struct p > #ifndef irqentry_state > typedef struct irqentry_state { > bool exit_rcu; > + bool lockdep; > } irqentry_state_t; Building on what Peter said do you agree this should be made into a union? It may not be strictly necessary in this patch but I think it would reflect the mutual exclusivity better and could be changed easy enough in the follow on patch which adds the pkrs state. Ira