From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DB21298CC4 for ; Mon, 24 Nov 2025 19:52:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764013980; cv=none; b=q4rlWQGiIV+btuYXrA61p0ZN1fwudEhOH8acMruvIYuZfSqxgWiZTePmVrmlGDPnaQLHpv2Qe4Gx/1bF6Xc6NOOvfQmZOSg1VcNZDEBW1tnwnyTAtCZSWuUcJjzGiX3WVe6dzwK5fYHrLS1cpDpLzDRrTXTggilaQJdkJ+Xlifc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764013980; c=relaxed/simple; bh=7yQkTnU6EMUyWJJWpfaiJgWDhOTYKY7pBae4ZQj688c=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ywn2yHvPLGDfnzhebQUacwJ9rU4EPYRItE+GgbHicJHVbZP2VSACmhEQZZ07UG5dKM16EjPu/8j0Tx9IomrEXwj/qfdqeBDwflZdmmQr1xZhgFNOTVnMzv9DHwyN1LXEYb960YxAhTlgCd+qUEj+LbeK3Qb+QvIpu0hHo20PnZM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=T7cThvrW; arc=none smtp.client-ip=198.175.65.16 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="T7cThvrW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1764013974; x=1795549974; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=7yQkTnU6EMUyWJJWpfaiJgWDhOTYKY7pBae4ZQj688c=; b=T7cThvrWVymxAZSqXsmsJMVZjWrj0laplELCRUZGWVGRECsrHLueSWaJ IXZnrmpYKsHMNJirHv8UggzYJLiEekaIXQgNm2bBNu8ng76cOEuNV+G68 I85mR3NJUOXKUxze6/cuKroDQovmGMNgiJH53IPf4HaFr5ISeUhou5Nlc 4Yvha/mhLt2knU1We2dBbhxnA5X2K+s8GkVgq3A727O1w2iWTCxNAYmkz CvVpu0DnKCRMlRyMc6oe43YDrAy67/YrPB1W5bQwqcgRATcwkMlPuLgDx qRkyCMwlg3C4n/JHwNAqDA7+TsHsjAi7Y4jQ03vSR5c2xiBr8IYGTJehL w==; X-CSE-ConnectionGUID: KvE+bTc/T6Ceg2sAcQ3GYQ== X-CSE-MsgGUID: HyUGBYlbTu+HrNtdACz7nA== X-IronPort-AV: E=McAfee;i="6800,10657,11623"; a="66184080" X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="66184080" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa108.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 11:52:54 -0800 X-CSE-ConnectionGUID: xEKXCNjpSEujSYiw47iKaw== X-CSE-MsgGUID: DLDS3QRdQaSinAkc4J+jSg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,223,1758610800"; d="scan'208";a="223401752" Received: from egrumbac-mobl6.ger.corp.intel.com (HELO localhost) ([10.245.244.5]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Nov 2025 11:52:52 -0800 Date: Mon, 24 Nov 2025 21:52:49 +0200 From: "andriy.shevchenko@linux.intel.com" To: "Stamatis, Ilias" Cc: "nadav.amit@gmail.com" , "david@kernel.org" , "linux-mm@kvack.org" , "akpm@linux-foundation.org" , "linux-kernel@vger.kernel.org" , "bhe@redhat.com" , "huang.ying.caritas@gmail.com" , "nh-open-source@amazon.com" Subject: Re: [PATCH] Reinstate "resource: avoid unnecessary lookups in find_next_iomem_res()" Message-ID: References: <20251124165349.3377826-1-ilstam@amazon.com> <20251124085816.07dbf5a4ec6235b2943840a0@linux-foundation.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs, Bertel Jungin Aukio 5, 02600 Espoo On Mon, Nov 24, 2025 at 07:35:31PM +0000, Stamatis, Ilias wrote: > On Mon, 2025-11-24 at 20:55 +0200, andriy.shevchenko@linux.intel.com wrote: > > On Mon, Nov 24, 2025 at 06:01:35PM +0000, Stamatis, Ilias wrote: > > > On Mon, 2025-11-24 at 08:58 -0800, Andrew Morton wrote: > > > > On Mon, 24 Nov 2025 16:53:49 +0000 Ilias Stamatis wrote: > > > > > > > > > Commit 97523a4edb7b ("kernel/resource: remove first_lvl / siblings_only > > > > > logic") removed an optimization introduced by commit 756398750e11 > > > > > ("resource: avoid unnecessary lookups in find_next_iomem_res()"). That > > > > > was not called out in the message of the first commit explicitly so it's > > > > > not entirely clear whether removing the optimization happened > > > > > inadvertently or not. > > > > > > > > > > As the original commit message of the optimization explains there is no > > > > > point considering the children of a subtree in find_next_iomem_res() if > > > > > the top level range does not match. Reinstating the optimization results > > > > > in significant performance improvements in systems with very large iomem > > > > > maps when mmaping /dev/mem. > > > > > > > > It would be great if we could quantify "significant performance > > > > improvements"? > > > > > > Hi Andrew and Andy, > > > > > > You are right to call that out and apologies for leaving it vague. > > > > > > I've done my testing with older kernel versions in systems where `wc -l > > > /proc/iomem` can return ~5k. In that environment I see mmaping parts of > > > /dev/mem taking 700-1500μs without the optimisation and 10-50μs with the > > > optimisation. > > > > > > The real-world use case we care about is hypervisor live update where having to > > > do lots of these mmaps() serially can significantly affect the guest downtime > > > if the cost is 20-30x. > > > > Thanks for providing this information. > > > > > > It also would be good to know which exact function(s) is a bottleneck. > > > > > > Perf tracing shows that ~95% of CPU time is spent in find_next_iomem_res(), > > > > Have you investigated possibility to return that check directly into > > the culprit? > > I'm sorry, I don't understand this. Could you please clarify what you mean? > What do you consider to be the culprit and which check do you refer to? The mentioned patch removed the check for siblings from next_resource(). The function that your test case complains about is find_next_iomem_res(). Hence, have you tried to reinstantiate the (removed) check from next_resource() in find_next_iomem_res() and see if it helps? -- With Best Regards, Andy Shevchenko