Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp980253ybj; Tue, 5 May 2020 10:47:25 -0700 (PDT) X-Google-Smtp-Source: APiQypK+32zp0621J1kSlNmfqbuQJvxrwJetBChIVBjzlIgss0eBTe6YrCpgCXJuGUqHSQS3vam+ X-Received: by 2002:a17:906:c281:: with SMTP id r1mr4002723ejz.310.1588700845304; Tue, 05 May 2020 10:47:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588700845; cv=none; d=google.com; s=arc-20160816; b=xg8ztQqUHvDcZUn0jia3ET7xG5iWhMpkFWntpuKcov0yxwO3aXgV1KrKCqwJsQD2Es V7242Seit3JCkvhx6wQVrEe7R6ejQSwYhVM5Q+IHyJP6QkJnCqcf5oEuaBLjTnsc53v+ GExinPbPNX/HU9iEgxDF6S2fgEDlquRkc0k4hwdsQdxUGbv+sdGGEHbiOu9tt70bQz8b h1h9VfTWkgVlZb2Qx1+29ByPzLppalzoHLT52kpxNNM697s4aJWxoV2PtTepef7IaQeN wTCTNaV4cHsjTau/CFIiMFXMONZd5XAp6KA7S5HiqbhihbrYZvFu3gLfliXP/2JiPI86 0aXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=2nj4RSbKJyuL9JmbuKJXoHQ8W5tgRAkbOjvomLKajgQ=; b=ZCMuLDOAgb1B0JVu4jXXbIDCFHpH0ufIA3C9s9WNtpvrxr4uRHvJKd0TAMSOpAYHlK qt1NR1u6EOU6KTN2yQQylECor+ErDeXkkK71VgwQofFdRzn2R14eCYc2LL/qv1wsOM7v 8pKddz+0FyzAEEqFaAzGSzTQXngI9+1CNDVgAcJK+j8imssxXvAFmQzY0OOHF8G6GO6C GQGSNuXTiPxHNlpFzZf7ApcNM+unG8/2JN+KroR1bbg1R6tqqib0M4yCoSNO5sUYj6bt /ML5h5HfodpNa56X2JEMi18UHax3ZuB+bEqEFewfwG5744cI8+pWfHW9oF348D4t+NTb DunA== 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=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s7si1493705edy.460.2020.05.05.10.47.02; Tue, 05 May 2020 10:47:25 -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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730682AbgEERpT (ORCPT + 99 others); Tue, 5 May 2020 13:45:19 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:7924 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730660AbgEERpR (ORCPT ); Tue, 5 May 2020 13:45:17 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 045H4uMf053335; Tue, 5 May 2020 13:44:43 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 30s50gvc1f-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2020 13:44:43 -0400 Received: from m0098414.ppops.net (m0098414.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 045H5HBO054487; Tue, 5 May 2020 13:44:42 -0400 Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0b-001b2d01.pphosted.com with ESMTP id 30s50gvc0k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2020 13:44:42 -0400 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.0.27/8.16.0.27) with SMTP id 045Hf6AZ027770; Tue, 5 May 2020 17:44:40 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04ams.nl.ibm.com with ESMTP id 30s0g5qe8w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 05 May 2020 17:44:40 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 045HicqQ65995104 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 5 May 2020 17:44:38 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8EC0F4203F; Tue, 5 May 2020 17:44:38 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BAA9F42042; Tue, 5 May 2020 17:44:33 +0000 (GMT) Received: from [9.102.27.216] (unknown [9.102.27.216]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 5 May 2020 17:44:33 +0000 (GMT) Subject: Re: [RFC][PATCH] kexec: Teach indirect pages how to live in high memory To: "Eric W. Biederman" , Joonsoo Kim Cc: kernel-team@lge.com, Michal Hocko , Minchan Kim , "Aneesh Kumar K . V" , Rik van Riel , "Rafael J . Wysocki" , LKML , Christian Koenig , Christoph Hellwig , Linux Memory Management List , Huang Rui , Kexec Mailing List , Pavel Machek , Johannes Weiner , Joonsoo Kim , Andrew Morton , Laura Abbott , Mel Gorman , Roman Gushchin , Vlastimil Babka References: <1588130803-20527-1-git-send-email-iamjoonsoo.kim@lge.com> <1588130803-20527-4-git-send-email-iamjoonsoo.kim@lge.com> <87h7wzvjko.fsf@x220.int.ebiederm.org> <87ftcfpzjn.fsf@x220.int.ebiederm.org> <87368fmkel.fsf_-_@x220.int.ebiederm.org> From: Hari Bathini Message-ID: <54a53bfe-6929-2790-9b1d-943e9f47cd62@linux.ibm.com> Date: Tue, 5 May 2020 23:14:32 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <87368fmkel.fsf_-_@x220.int.ebiederm.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-05-05_09:2020-05-04,2020-05-05 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1011 impostorscore=0 adultscore=0 priorityscore=1501 malwarescore=0 phishscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 bulkscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2005050131 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/05/20 3:29 am, Eric W. Biederman wrote: > > Recently a patch was proposed to kimage_alloc_page to slightly alter > the logic of how pages allocated with incompatible flags were > detected. The logic was being altered because the semantics of the > page alloctor were changing yet again. > > Looking at that case I realized that there is no reason for it to even > exist. Either the indirect page allocations and the source page > allocations could be separated out, or I could do as I am doing now > and simply teach the indirect pages to live in high memory. > > This patch replaced pointers of type kimage_entry_t * with a new type > kimage_entry_pos_t. This new type holds the physical address of the > indirect page and the offset within that page of the next indirect > entry to write. A special constant KIMAGE_ENTRY_POS_INVALID is added > that kimage_image_pos_t variables that don't currently have a valid > may be set to. > > Two new functions kimage_read_entry and kimage_write_entry have been > provided to write entries in way that works if they live in high > memory. > > The now unnecessary checks to see if a destination entry is non-zero > and to increment it if so have been removed. For safety new indrect > pages are now cleared so we have a guarantee everything that has not > been used yet is zero. Along with this writing an extra trailing 0 > entry has been removed, as it is known all trailing entries are now 0. > > With highmem support implemented for indirect pages > kimage_image_alloc_page has been updated to always allocate > GFP_HIGHUSER pages, and handling of pages with different > gfp flags has been removed. > > Signed-off-by: "Eric W. Biederman" Eric, the patch failed with data access exception on ppc64. Using the below patch on top got me going... diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 45862fd..bef52f1 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -570,7 +570,12 @@ static int kimage_add_entry(struct kimage *image, kimage_entry_t entry) return -ENOMEM; ind_addr = page_to_boot_pfn(page) << PAGE_SHIFT; - kimage_write_entry(image->entry_pos, ind_addr | IND_INDIRECTION); + + /* If it is the first entry, handle it here */ + if (!image->head) + image->head = ind_addr | IND_INDIRECTION; + else + kimage_write_entry(image->entry_pos, ind_addr | IND_INDIRECTION); clear_highpage(page); @@ -623,7 +628,11 @@ int __weak machine_kexec_post_load(struct kimage *image) void kimage_terminate(struct kimage *image) { - kimage_write_entry(image->entry_pos, IND_DONE); + /* This could be the only entry in case of kdump */ + if (!image->head) + image->head = IND_DONE; + else + kimage_write_entry(image->entry_pos, IND_DONE); } #define for_each_kimage_entry(image, pos, entry) \ Thanks Hari