Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp192967lqb; Tue, 4 Jun 2024 08:41:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWqRBpQscLiPrc9DYU0e1LW9MKMtLoTWyVsYHG50mjIQXRkjGMKVluEfw+VVCkmoORtJBt72SYde8fgSDl/dqA5dGdIM20DkvZTyUKOYw== X-Google-Smtp-Source: AGHT+IGgSAQCySdxrGOTNkg+de6Sf3X27SNKm+6dbWwdpJ8dPDpTdybzOPqCjx2rO8yOE9Yymy4M X-Received: by 2002:a50:ab03:0:b0:572:4702:2227 with SMTP id 4fb4d7f45d1cf-57a36450a5bmr7987609a12.35.1717515713481; Tue, 04 Jun 2024 08:41:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717515713; cv=pass; d=google.com; s=arc-20160816; b=N8VQp3S7HDvxdCBCZcUA2hc7gWUqfCFqkgImxdyJWhIKbRaSoanJXevjQMRIMDR42Z LXnayDRUkxApwLPxPOASd4NBm98NeEceGwUtHiJwa+CCHErOB3/x6DSgLEvU7O7gWpt1 AiPobohzGOp/77a+5ObwcpPHoL7rFmf1ES4kMpgl5nzAVCQynrEnY0FiWld7HhmPCbVS 1fzEKws4Jo1gCR8aCCXpmsKcKXoO6ujRim+t2uzoo0vFWBpRBRsHvQ0Ih3sEWIF/ix9K yPSbXLbt2XfJkTEO4rBwKZDuRt33qLLi8S19JXd3nNG1C1KbqV240Uv8oXZxfni/V4GR K1CQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1OpeZekwL9p9WpE0H+gpRuIdi1IMywvK4QtT+HtBl6A=; fh=htroj5ErFeS5QWJJ7gdlJwBah3kX5zd7pU3Pa5VadS8=; b=nDsZhd9Xa1O0uJI91Tz7IuryqfCuLNqOZ9IZbnUrQvhYtTCXQaDebHYJyTlT+Sdwcn gVfD7MeiPJWyiNJCG2Tnl3D0siV0mr9LYbKjfVkbP/F5tUCls7CSrfpwB5v0j3Ns7RkM UCkNhsubvLgj4S3s2k0OboB6+FFfPkycCNBfniobLTht8cfQgpALaPmKitf1gq8XitKn lXSbrdc9lthNdyZa1diI2SSTNc3kOtcUF5e2e6scXt7MWoIiyMjHcvOIU+I8fatkJ/2i aUZL73hAWm868uHKk+46/eOu8V11LhmkTYEolb/MNm9iJkiiE9dnJ4Xa4YXKhwPpY3a8 Wpew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QFYHrfR2; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-200973-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200973-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57a31b80b59si5175488a12.7.2024.06.04.08.41.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 08:41:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200973-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QFYHrfR2; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-200973-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200973-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 35EB41F267EF for ; Tue, 4 Jun 2024 15:41:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 752F2144D10; Tue, 4 Jun 2024 15:41:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="QFYHrfR2" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 84EABBE4A for ; Tue, 4 Jun 2024 15:41:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717515705; cv=none; b=oInvFF4MFAOgcWuEbDt8E3ADRhsfge4JmbYVpglXsO6KcldaZ6DcD2xkXG41nFf993t598dNFYjONdStNJwaRFeJsLU0JHPJ3+IMnV98eMlRZGNERzkTPxo5RDOfES5zUi5niCRgPCw2dSQcnFZwEOPnFzhGTZDaY1QZoigNao4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717515705; c=relaxed/simple; bh=MkqW4oRMkhNEdYOvDU8SXsza2MZUGZIzZNiOeC/dQY8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=o/cgN6W0w4yM+ocxmUPQWKawni8cG3owAn1hsqN3y6nnaP8cbjmuNuQnUQTZwRfdf8srLS8C09NK+XjSEjmGyd7Atvcr1vicSYPqi/prU/+XTTH0amwORi0pKNqqSLlrHtcsfGQMwVG3qu5nrNfBTDxb4jxQGZXZPICUnoB2X8U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=QFYHrfR2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 419ADC2BBFC; Tue, 4 Jun 2024 15:41:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1717515705; bh=MkqW4oRMkhNEdYOvDU8SXsza2MZUGZIzZNiOeC/dQY8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=QFYHrfR2wBDLSr/NAUq7a4NDJajg6kry2t9DxkVnMJNuCwbyEticVZz7z2cXgWxSV W/tFV8bzudGtOLJnKhHl1GTe7pvxoBR5+Kc53ItMaFHBUJT0bjGH7NoEruB+u04AF/ QvjXc0tth8Ny884yL9+o4j1zEe6gYh2NE+pGVcfU= Date: Tue, 4 Jun 2024 17:31:50 +0200 From: Greg Kroah-Hartman To: Chia-I Wu Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, christian.koenig@amd.com, alexander.deucher@amd.com, Andy Shevchenko , Alison Schofield , Dave Jiang , Baoquan He , linux-kernel@vger.kernel.org Subject: Re: [PATCH] kernel/resource: optimize find_next_iomem_res Message-ID: <2024060427-upstairs-jackal-b10a@gregkh> References: <20240531053704.2009827-1-olvaffe@gmail.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240531053704.2009827-1-olvaffe@gmail.com> On Thu, May 30, 2024 at 10:36:57PM -0700, Chia-I Wu wrote: > We can skip children resources when the parent resource does not cover > the range. > > This should help vmf_insert_* users on x86, such as several DRM drivers. > On my AMD Ryzen 5 7520C, when streaming data from cpu memory into amdgpu > bo, the throughput goes from 5.1GB/s to 6.6GB/s. perf report says > > 34.69%--__do_fault > 34.60%--amdgpu_gem_fault > 34.00%--ttm_bo_vm_fault_reserved > 32.95%--vmf_insert_pfn_prot > 25.89%--track_pfn_insert > 24.35%--lookup_memtype > 21.77%--pat_pagerange_is_ram > 20.80%--walk_system_ram_range > 17.42%--find_next_iomem_res > > before this change, and > > 26.67%--__do_fault > 26.57%--amdgpu_gem_fault > 25.83%--ttm_bo_vm_fault_reserved > 24.40%--vmf_insert_pfn_prot > 14.30%--track_pfn_insert > 12.20%--lookup_memtype > 9.34%--pat_pagerange_is_ram > 8.22%--walk_system_ram_range > 5.09%--find_next_iomem_res > > after. That's great, but why is walk_system_ram_range() being called so often? Shouldn't that be a "set up the device" only type of thing? Why hammer on "lookup_memtype" when you know the memtype, you just did the same thing for the previous frame. This feels like it could be optimized to just "don't call these things" which would make it go faster, right? What am I missing here, why does this always have to be calculated all the time? Resource mapping changes are rare, if at all, over the lifetime of a system uptime. Constantly calculating something that never changes feels odd to me. thanks, greg k-h