Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754860AbbGTDaE (ORCPT ); Sun, 19 Jul 2015 23:30:04 -0400 Received: from mga09.intel.com ([134.134.136.24]:5686 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754225AbbGTDaD (ORCPT ); Sun, 19 Jul 2015 23:30:03 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,506,1432623600"; d="scan'208";a="765712212" Message-ID: <55AC6A94.5070700@intel.com> Date: Mon, 20 Jul 2015 11:27:16 +0800 From: Pan Xinhui User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Thomas Gleixner CC: linux-kernel@vger.kernel.org, mingo@redhat.com, hpa@zytor.com, x86@kernel.org, bp@suse.de, jgross@suse.com, mcgrof@suse.com, decui@microsoft.com, ross.zwisler@linux.intel.com, sfr@canb.auug.org.au, toshi.kani@hp.com, "mnipxh@163.com" Subject: Re: [PATCH] x86/mm/pat: let level meaningful even NULL return in, lookup_address_in_pgd References: <55A5048E.3090403@intel.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2344 Lines: 65 hi, tglx thanks for your reply. On 2015年07月17日 22:50, Thomas Gleixner wrote: > On Tue, 14 Jul 2015, Pan Xinhui wrote: >> If pmd or pud is not set, we may set a wrong page mapping level. > > No. The behaviour is simply undefined, if the return value of the > function is NULL. > > So what you are trying to do is to make the level information accurate > even for the failure case. > yes. it's good to report level information. then we can handle some errors. >> We know *address* belongs to *pud*, however for some reasons *pmd* is >> NULL. For example, this address has no physical pages mapped. What we >> could benefit from this patch are below: >> 1) We can walk memory range easier. >> If addressA passed to lookup_address(), and NULL returned. We can pass >> addressA + level_to_size(level) to lookup_address() in next loop. >> ... >> if (!pte) { >> /* level_to_size has not been implemented in upstream*/ >> address += level_to_size(level); >> continue; >> } > > This example is completely useless because we do not see how the loop > itself looks like and how that improves anything. The proper way to do > this is to post: > > - the patch which changes the function > - another patch which makes use of the change > > But so far I cannot see any reason why we want to change it. > sorry for that. There are some debug patches protected. I will try to make a simple example in other mails. >> ... >> 2) keep same behavior because level is set to PG_LEVEL_4K even when pte >> is NULL. > > And what's the actual benefit of #2? Keeping the same behaviour is a > requirement if you don't want to break any users of that function. > agree with you. :) I did not explain it in correct ways. When pte is NULL, lookup_address will return NULL on failure. however the level is correct and set to PG_LEVEL_4K. So what I am trying to do is that if lookup_address return NULL on *pud* or *pmd* NULL failure, level is still correct or more correct. A correct level information is very useful when we walk a large range of memory. thanks xinhui > Thanks, > > tglx > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/