Re: [PATCH 3/3] mm/sparse: use __highest_present_section_nr as the boundary for pfn check
From: Michal Hocko <mhocko@suse.com>
Date: 2018-08-23 19:17:35
On Thu 23-08-18 16:00:53, Oscar Salvador wrote:
On Thu, Aug 23, 2018 at 03:25:26PM +0200, Michal Hocko wrote:quoted
On Thu 23-08-18 21:07:32, Wei Yang wrote:quoted
And it is known, __highest_present_section_nr is a more strict boundary than NR_MEM_SECTIONS. This patch uses a __highest_present_section_nr to check a valid pfn.But why is this an improvement? Sure when you loop over all sections than __highest_present_section_nr makes a lot of sense. But all the updated function perform a trivial comparision.I think it makes some sense. NR_MEM_SECTIONS can be a big number, but we might not be using all sections, so __highest_present_section_nr ends up being a much lower value.
And how exactly does it help to check for the smaller vs. a larger number? Both are O(1) operations AFAICS. __highest_present_section_nr makes perfect sense when we iterate over all sections or similar operations where it smaller number of iterations really makes sense. I am not saying the patch is wrong but I just do not see this being an improvement. You have to export an internal symbol to achieve something that is hardly an optimization. -- Michal Hocko SUSE Labs