Received: by 2002:ac0:c50a:0:0:0:0:0 with SMTP id y10csp1213784imi; Fri, 1 Jul 2022 05:32:53 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v6U/2lsFsJuvgEoREER9Gkmh5/M250uLYGdR/u9QzEXcei75vCRXzWyP3Q5MHw8baWD4ww X-Received: by 2002:aa7:c14f:0:b0:435:7b75:fd06 with SMTP id r15-20020aa7c14f000000b004357b75fd06mr18611726edp.352.1656678773161; Fri, 01 Jul 2022 05:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656678773; cv=none; d=google.com; s=arc-20160816; b=vbpXqA3rDEDlRD0Vc1WH0DN2Z5xUNvxZ7wv5f+mOOEEEwUgV/XG/ZORcO/9y/fRaUX 55bl6Qw5HDSuB8AHcH3PWI52xAuwuhUxoh6+UdcV/H5EKyWA6J2rWk4wgPEdn1dnDLUm +UhmnB5Uz+eYtK1fArosZpxiONoUhg/maYyddwiI96gaWqdDIvULRKxTI7h2NAZAgEx7 AN+5es3ckPQh3zai1uUZ/ZX+pRuMznyQU2jpM+9/08b2aYRwOvwNCPMrmj+mZJLLwc0N ZAbZH3vFhnhNIlZHV3FOiiLdfvuPh8B3SldEs8l9bHbIIYDmfq9qBxYizPSJNbdiiLvU TqlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=2g9fSCa6kW+2G0EWF+D4LK/1cp5VRievk8PPx3pw1Aw=; b=Xp06ZcI4Ev5UNnnxl+9PblUcRyp81L3+kilg9u2H1mFxBVYhytICXKe5tpMzX7Q8cU c5pKOvMtTqDVGJ2WzDSZ0RL982x0ZJ+dsjLbGF0pIbEnls4v/6cJpNHHgUTD+fbfyDzO QB8OmZjJfCqKaRa2YZgiL94M96X5jyDBy2p/3jEvExCpGo6AcI09P4/Jft8f9HECAgQQ sh6jABcvozUDeXFmj2xxwYvmJS8SXTV2Nek6lwl1n9DhC2toQrFgmfZqYYeFNknqjigP C3BBSrJ+Xdpe+DkfLRpkQ0EEK6RClF9NC/nssS6zZhy4TgjOo83OL6JpQ49je8xLgvA4 wY6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a23-20020a50c317000000b0043964c389e5si4402088edb.506.2022.07.01.05.32.28; Fri, 01 Jul 2022 05:32:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235750AbiGAMBu (ORCPT + 99 others); Fri, 1 Jul 2022 08:01:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233193AbiGAMBl (ORCPT ); Fri, 1 Jul 2022 08:01:41 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 19B8583F2C for ; Fri, 1 Jul 2022 05:01:39 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1C4AB113E; Fri, 1 Jul 2022 05:01:39 -0700 (PDT) Received: from [10.57.85.162] (unknown [10.57.85.162]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E838D3F792; Fri, 1 Jul 2022 05:01:36 -0700 (PDT) Message-ID: <1eeeec76-5271-f915-e3fd-f15095efb981@arm.com> Date: Fri, 1 Jul 2022 13:01:31 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] iommu/iova: change IOVA_MAG_SIZE to 127 to save memory Content-Language: en-GB To: John Garry , Feng Tang Cc: Joerg Roedel , Will Deacon , iommu@lists.linux-foundation.org, iommu@lists.linux.dev, Andrew Morton , Christoph Lameter , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Paul Menzel References: <20220630073304.26945-1-feng.tang@intel.com> <13db50bb-57c7-0d54-3857-84b8a4591d9e@arm.com> <7c29d01d-d90c-58d3-a6e0-0b6c404173ac@huawei.com> <117b31b5-8d06-0af4-7f1c-231d86becf1d@arm.com> <2920df89-9975-5785-f79b-257d3052dfaf@huawei.com> <20220701035622.GB14806@shbuild999.sh.intel.com> <51af869a-83d4-631a-2d91-edb8b066bf4d@huawei.com> From: Robin Murphy In-Reply-To: <51af869a-83d4-631a-2d91-edb8b066bf4d@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022-07-01 12:33, John Garry wrote: > On 01/07/2022 04:56, Feng Tang wrote: >>>> inclination. >>>> >>> ok, what you are saying sounds reasonable. I just remember that when we >>> analyzed the longterm aging issue that we concluded that the FQ size >>> and its >>> relation to the magazine size was a factor and this change makes me a >>> little >>> worried about new issues. Better the devil you know and all that... >>> >>> Anyway, if I get some time I might do some testing to see if this >>> change has >>> any influence. >>> >>> Another thought is if we need even store the size in the >>> iova_magazine? mags >>> in the depot are always full. As such, we only need worry about mags >>> loaded >>> in the cpu rcache and their sizes, so maybe we could have something like >>> this: >>> >>> struct iova_magazine { >>> -       unsigned long size; >>>         unsigned long pfns[IOVA_MAG_SIZE]; >>> }; >>> >>> @@ -631,6 +630,8 @@ struct iova_cpu_rcache { >>>         spinlock_t lock; >>>         struct iova_magazine *loaded; >>>         struct iova_magazine *prev; >>> +       int loaded_size; >>> +       int prev_size; >>> }; >>> >>> I haven't tried to implement it though.. >> I have very few knowledge of iova, so you can chose what's the better >> solution. I just wanted to raise the problem and will be happy to see >> it solved:) > > I quickly tested your patch for performance and saw no noticeable > difference, which is no surprise. > > But I'll defer to Robin if he thinks that your patch is a better > solution - I would guess that he does. For me personally I would prefer > that this value was not changed, as I mentioned before. This idea is interesting, but it would mean a bit more fiddly work to keep things in sync when magazines are allocated, freed and swapped around. It seems like the kind of non-obvious thing that might make sense if it gave a significant improvement in cache locality or something like that, but for simply fixing an allocation size it feels a bit too wacky. From my perspective, indeed I'd rather do the simple thing for now to address the memory wastage issue directly, then we can do the deeper performance analysis on top to see if further tweaking of magazine sizes and/or design is justified. Cheers, Robin.