Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3665048imm; Mon, 25 Jun 2018 02:30:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIs85gT6s4I0VEOmdQ3lxk+OA/bgaRSJGFj5fA9OwJ1842N0Pz+9YgChL8QeqYTzc5nVmmh X-Received: by 2002:a62:e117:: with SMTP id q23-v6mr12362910pfh.75.1529919034538; Mon, 25 Jun 2018 02:30:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529919034; cv=none; d=google.com; s=arc-20160816; b=u4JGIdK7j+KoH0qJXL9cjCcn2DdyzzwGOL4ceyLquE/YLQgaMnv/J/9s7wcYNUPtEu JSEHX5ZwecH/52UBxIe7AxM+yGIQFAjaA2BnDhb2gQqXk45hjrt03sAq3U9VT5w0+WPd Hy8x5iEInFpxiZB8Sv2qx832asbzScSsf8lAJtKQ6YUULb8Q9SxyRsJJKU8c56PKvKZ8 e/T2mslkrTy7MIoZnbSlOsgqoYurZEuiGuuYhV9EUb7FiKsZMC9EHpmwYlhm/7FfoG38 6MfEJ16ptwsbO856s9rO98xlJ13Ozh2SQkDr0A+zI2nzLgmntv1MLke/eOLeTS3pFCxJ gMvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=ErNeQDMo3TsxUEbYne97tEU7w5wP1RbEa5KhL8wC9iI=; b=asSqnREYh4+L/T56yCuWWJxrsBkVV1KJuK35o4aN6XyMXRUQX9Tt0L99MmwqLAJ1XM Sm8XwkfDk+vBvKmMW0gldWSPhopJzCfvaUzl4Z3cT4dWxZtO+NB+AY1O2DXFuZRMSTRh Hk18DgFRDClDf5vak9vSCWULfYF1astO2Z1P0K2dfCF9HCA5GPptbL1rKWm/lf3cW5xE 7YXSJikATNkEF41zpwQfACwPWh8Fj+msJI8ZXzDgVF1+fh6hstcTgTtW50kKGd/+WMQa URQuG46c/ouYm8sEq34MnlOPlo7WoxX+okoXnjviWw5csvtyiMHCArS0bY01V9Phtx2s FBSA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id y7-v6si13752623pfy.140.2018.06.25.02.30.20; Mon, 25 Jun 2018 02:30:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1754851AbeFYJ3k (ORCPT + 99 others); Mon, 25 Jun 2018 05:29:40 -0400 Received: from mga05.intel.com ([192.55.52.43]:43478 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752620AbeFYJ3j (ORCPT ); Mon, 25 Jun 2018 05:29:39 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jun 2018 02:29:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,269,1526367600"; d="scan'208";a="49677778" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga007.fm.intel.com with ESMTP; 25 Jun 2018 02:29:36 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 77F652DF; Mon, 25 Jun 2018 12:29:38 +0300 (EEST) Date: Mon, 25 Jun 2018 12:29:38 +0300 From: "Kirill A. Shutemov" To: Dave Hansen Cc: Ingo Molnar , x86@kernel.org, Thomas Gleixner , "H. Peter Anvin" , Tom Lendacky , Kai Huang , Jacob Pan , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv3 15/17] x86/mm: Implement sync_direct_mapping() Message-ID: <20180625092937.gmu6m7kwet5s5w6m@black.fi.intel.com> References: <20180612143915.68065-1-kirill.shutemov@linux.intel.com> <20180612143915.68065-16-kirill.shutemov@linux.intel.com> <848a6836-1f54-4775-0b87-e926d7b7991d@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <848a6836-1f54-4775-0b87-e926d7b7991d@intel.com> User-Agent: NeoMutt/20170714-126-deb55f (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 18, 2018 at 04:28:27PM +0000, Dave Hansen wrote: > > index 17383f9677fa..032b9a1ba8e1 100644 > > --- a/arch/x86/mm/init_64.c > > +++ b/arch/x86/mm/init_64.c > > @@ -731,6 +731,8 @@ kernel_physical_mapping_init(unsigned long paddr_start, > > pgd_changed = true; > > } > > > > + sync_direct_mapping(); > > + > > if (pgd_changed) > > sync_global_pgds(vaddr_start, vaddr_end - 1); > > > > @@ -1142,10 +1144,13 @@ void __ref vmemmap_free(unsigned long start, unsigned long end, > > static void __meminit > > kernel_physical_mapping_remove(unsigned long start, unsigned long end) > > { > > + int ret; > > start = (unsigned long)__va(start); > > end = (unsigned long)__va(end); > > > > remove_pagetable(start, end, true, NULL); > > + ret = sync_direct_mapping(); > > + WARN_ON(ret); > > } > > I understand why you implemented it this way, I really do. It's > certainly the quickest way to hack something together and make a > standalone piece of code. But, I don't think it's maintainable. > > For instance, this call to sync_direct_mapping() could be entirely > replaced by a call to: > > for_each_keyid(k)... > remove_pagetable(start + offset_per_keyid * k, > end + offset_per_keyid * k, > true, NULL); > > No? Yes. But what's the point if we need to have the sync routine anyway for the add path? > > int __ref arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap) > > @@ -1290,6 +1295,7 @@ void mark_rodata_ro(void) > > (unsigned long) __va(__pa_symbol(rodata_end)), > > (unsigned long) __va(__pa_symbol(_sdata))); > > > > + sync_direct_mapping(); > > debug_checkwx(); > > Huh, checking the return code in some cases and not others. Curious. > Why is it that way? There's no sensible way to handle failure in any of these path. But in remove path we don't expect the failure -- no allocation required. It can only happen if we missed sync_direct_mapping() somewhere else. -- Kirill A. Shutemov