Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751700AbdCQRnz (ORCPT ); Fri, 17 Mar 2017 13:43:55 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:45746 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751057AbdCQRnx (ORCPT ); Fri, 17 Mar 2017 13:43:53 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Xunlei Pang Cc: linux-kernel@vger.kernel.org, kexec@lists.infradead.org, akpm@linux-foundation.org, Dave Young , Baoquan He , "H. Peter Anvin" , Ingo Molnar , x86@kernel.org References: <1489746150-28364-1-git-send-email-xlpang@redhat.com> Date: Fri, 17 Mar 2017 12:38:49 -0500 In-Reply-To: <1489746150-28364-1-git-send-email-xlpang@redhat.com> (Xunlei Pang's message of "Fri, 17 Mar 2017 18:22:30 +0800") Message-ID: <8737ebg5w6.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1covuj-0007dD-Px;;;mid=<8737ebg5w6.fsf@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=67.3.234.240;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+grj1kmKJpBfJfrbv7CJDJkYKGoL/XjCg= X-SA-Exim-Connect-IP: 67.3.234.240 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.7 XMSubLong Long Subject * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa01 1397; Body=1 Fuz1=1 Fuz2=1] * 0.1 XMSolicitRefs_0 Weightloss drug * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa01 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Xunlei Pang X-Spam-Relay-Country: X-Spam-Timing: total 955 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 3.2 (0.3%), b_tie_ro: 2.3 (0.2%), parse: 1.39 (0.1%), extract_message_metadata: 20 (2.1%), get_uri_detail_list: 17 (1.8%), tests_pri_-1000: 6 (0.6%), tests_pri_-950: 2.0 (0.2%), tests_pri_-900: 14 (1.5%), tests_pri_-400: 56 (5.9%), check_bayes: 54 (5.6%), b_tokenize: 15 (1.6%), b_tok_get_all: 12 (1.2%), b_comp_prob: 6 (0.6%), b_tok_touch_all: 7 (0.8%), b_finish: 0.87 (0.1%), tests_pri_0: 810 (84.9%), check_dkim_signature: 0.89 (0.1%), check_dkim_adsp: 4.3 (0.5%), tests_pri_500: 7 (0.7%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH] x86_64, kexec: Avoid unnecessary identity mappings for kdump X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3591 Lines: 96 Xunlei Pang writes: > kexec setups identity mappings for all the memory mapped in 1st kernel, > this is not necessary for the kdump case. Actually it can cause extra > memory consumption for paging structures, which is quite considerable > on modern machines with huge memory. > > E.g. On our 24TB machine, it will waste around 96MB (around 4MB/TB) > from the reserved memory range if setting all the identity mappings. > > It also causes some trouble for distributions that use an intelligent > policy to evaluate the proper "crashkernel=X" for users. > > To solve it, in case of kdump, we only setup identity mappings for the > crash memory and the ISA memory(may be needed by purgatory/kdump > boot). How about instead we detect the presence of 1GiB pages and use them if they are available. We already use 2MiB pages. If we can do that we will only need about 192K for page tables in the case you have described and this all becomes a non-issue. I strongly suspect that the presence of 24TiB of memory in an x86 system strongly correlates to the presence of 1GiB pages. In principle we certainly can use a less extensive mapping but that should not be something that differs between the two kexec cases. I can see forcing the low 1MiB range in. But calling it ISA range is very wrong and misleading. The reasons that range are special during boot-up have nothing to do with ISA. But have everything to do with where legacy page tables are mapped, and where we need identity pages to start other cpus. I think the only user that actually cares is purgatory where it plays swapping games with the low 1MiB because we can't preload what we need to down there or it would mess up the running kernel. So saying anything about the old ISA bus is wrong and misleading. At the very very least we need accurate comments. Eric > > Signed-off-by: Xunlei Pang > --- > arch/x86/kernel/machine_kexec_64.c | 34 ++++++++++++++++++++++++++++++---- > 1 file changed, 30 insertions(+), 4 deletions(-) > > diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c > index 857cdbd..db77a76 100644 > --- a/arch/x86/kernel/machine_kexec_64.c > +++ b/arch/x86/kernel/machine_kexec_64.c > @@ -112,14 +112,40 @@ static int init_pgtable(struct kimage *image, unsigned long start_pgtable) > > level4p = (pgd_t *)__va(start_pgtable); > clear_page(level4p); > - for (i = 0; i < nr_pfn_mapped; i++) { > - mstart = pfn_mapped[i].start << PAGE_SHIFT; > - mend = pfn_mapped[i].end << PAGE_SHIFT; > > + if (image->type == KEXEC_TYPE_CRASH) { > + /* Always map the ISA range */ > result = kernel_ident_mapping_init(&info, > - level4p, mstart, mend); > + level4p, 0, ISA_END_ADDRESS); > if (result) > return result; > + > + /* crashk_low_res may not be initialized when reaching here */ > + if (crashk_low_res.end) { > + mstart = crashk_low_res.start; > + mend = crashk_low_res.end + 1; > + result = kernel_ident_mapping_init(&info, > + level4p, mstart, mend); > + if (result) > + return result; > + } > + > + mstart = crashk_res.start; > + mend = crashk_res.end + 1; > + result = kernel_ident_mapping_init(&info, > + level4p, mstart, mend); > + if (result) > + return result; > + } else { > + for (i = 0; i < nr_pfn_mapped; i++) { > + mstart = pfn_mapped[i].start << PAGE_SHIFT; > + mend = pfn_mapped[i].end << PAGE_SHIFT; > + > + result = kernel_ident_mapping_init(&info, > + level4p, mstart, mend); > + if (result) > + return result; > + } > } > > /*