From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A03DC2BA19 for ; Thu, 23 Apr 2020 08:41:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D78D82084D for ; Thu, 23 Apr 2020 08:41:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Igt/Akh3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726849AbgDWIl2 (ORCPT ); Thu, 23 Apr 2020 04:41:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725854AbgDWIl2 (ORCPT ); Thu, 23 Apr 2020 04:41:28 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D62BC03C1AF for ; Thu, 23 Apr 2020 01:41:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=VvCgmpRO1TIV6jLSYYC9IwKA1wKGvUUGkl/XDJDIM9Q=; b=Igt/Akh3jfYnuGPuEjw0bOoN2e onVVx4h+2alkA3V9MFZlYUED0NgJGUE1xRCRM/4ovv+wyPBOhe+8egMYlI0ovJycoU1xXkhohR43O fhR90WCHYC/REGQVRF7/D1CEfBhDoONvGilwI5Q2V2C9KXAwysLxuhsz7AO4ntiC0j0DJwmA4ACgV kfYBI3ZgdUd+H94c8ZyjvYp7Dt3nVg7SqtWex4CyEljJ9A+ilBmTmyskL2sWLmi3FDllyUxVJoEml 2uPeWyznGObI+MwBG7D0AyAzbk9FU1Mml91IeZBIwKujnUN8tdlfW78bFPb/Y+Mo4rXMdnnLMXtAh FvqrdIFg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jRXQ5-0002kA-Hq; Thu, 23 Apr 2020 08:41:17 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 03772306099; Thu, 23 Apr 2020 10:41:15 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id E0A1220BE0448; Thu, 23 Apr 2020 10:41:14 +0200 (CEST) Date: Thu, 23 Apr 2020 10:41:14 +0200 From: Peter Zijlstra To: Rick Edgecombe Cc: dave.hansen@linux.intel.com, luto@kernel.org, tglx@linutronix.de, x86@kernel.org, mingo@redhat.com, bp@alien8.de, hpa@zytor.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/mm/cpa: Flush direct map alias during cpa Message-ID: <20200423084114.GS20713@hirez.programming.kicks-ass.net> References: <20200423031355.23955-1-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200423031355.23955-1-rick.p.edgecombe@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 22, 2020 at 08:13:55PM -0700, Rick Edgecombe wrote: > Change cpa_flush() to always flush_tlb_all(), as it previously did. As an > optimization, cpa_flush() was changed to optionally only flush the range > in "struct cpa_data *data" if it was small enough. However, this range > does not include any direct map aliases changed in cpa_process_alias(). > So small set_memory_() calls that touch that alias don't get the direct > map changes flushed. This situation can happen when the virtual address > taking variants are passed an address in vmalloc or modules space. Wouldn't something like so make more sense? --- diff --git a/arch/x86/mm/pat/set_memory.c b/arch/x86/mm/pat/set_memory.c index 59eca6a94ce7..b8c55a2e402d 100644 --- a/arch/x86/mm/pat/set_memory.c +++ b/arch/x86/mm/pat/set_memory.c @@ -43,7 +43,8 @@ struct cpa_data { unsigned long pfn; unsigned int flags; unsigned int force_split : 1, - force_static_prot : 1; + force_static_prot : 1, + force_flush_all : 1; struct page **pages; }; @@ -355,10 +356,10 @@ static void cpa_flush(struct cpa_data *data, int cache) return; } - if (cpa->numpages <= tlb_single_page_flush_ceiling) - on_each_cpu(__cpa_flush_tlb, cpa, 1); - else + if (cpa->force_flush_all || cpa->numpages > tlb_single_page_flush_ceiling) flush_tlb_all(); + else + on_each_cpu(__cpa_flush_tlb, cpa, 1); if (!cache) return; @@ -1598,6 +1599,8 @@ static int cpa_process_alias(struct cpa_data *cpa) alias_cpa.flags &= ~(CPA_PAGES_ARRAY | CPA_ARRAY); alias_cpa.curpage = 0; + cpa->force_flush_all = 1; + ret = __change_page_attr_set_clr(&alias_cpa, 0); if (ret) return ret; @@ -1618,6 +1621,7 @@ static int cpa_process_alias(struct cpa_data *cpa) alias_cpa.flags &= ~(CPA_PAGES_ARRAY | CPA_ARRAY); alias_cpa.curpage = 0; + cpa->force_flush_all = 1; /* * The high mapping range is imprecise, so ignore the * return value.