Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3695911rwl; Mon, 27 Mar 2023 18:44:05 -0700 (PDT) X-Google-Smtp-Source: AKy350ZPrnqokDN0bwjBdxts5Rfebk+9nIGBskHj7mtj3oWrjGtrh7tzelI2PCXCzsW+kon88Qot X-Received: by 2002:a17:903:1386:b0:1a2:1674:3900 with SMTP id jx6-20020a170903138600b001a216743900mr11762946plb.41.1679967845085; Mon, 27 Mar 2023 18:44:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679967845; cv=none; d=google.com; s=arc-20160816; b=Tp4jt3LsaZEDmi3/+QDRlsO0f4kkw4ckCsM0P8GRNkSsf0j7Z0vg3l8/0iYBXb+yhn qkRumqkgWWiDj2ZM2UwZroIyQm6WyjX8Qm5sp1s91lKt71ECwQF3sYSpPVGTaqIY53Df mJA6ilphtOcOD1XDjB/CULZfTfsQGMMqUFdqPgcNYBUWw0MmeGwmJM5Ti/KptMpsAiZF MqtmFDYdy8ENJrZqx45o5Un+0tlFVstvdrvrPhrmNNYudhCCpxG/yBCmakAsGJWn2SRr C9Z6FHZ5intTzpCQPeeZC04/WzP+Pc6bXDOtsWsJN85AhP7h6eC3L/FMrz4mN2Wp6rMb j//Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=zQ9VeEDyCA7TnGkpi51WEjNMAth9a21cJDmTyCBeKrY=; b=b745s7GfANDVJqNFZbFY8F3lj5dDEa30FthADATe2BZsnkFE6K0/VzWsXxqpoGvpNv hq7vcr0cUpsTelXGUKMZyrrWDUTV4kjRUn9oxkMhC/8DA/bfffkte/V0Tb5W0zAYNmkE kQRsgjGlBWELgTEOV9x0Vm5/7/bgJ9O446PmCExaQPqb0xktGZMV3ukSlSGKQR3JXkf3 J2UzgNy1uQwMzheXD8/3x1T0Vx0Vaduy5dt24mU7hES7IdM5x99865zN5VMGdQAz+5et tj5Dm8eZoEpoln4D/cZdxiaccbw9nwTP2B6oAzN68ND2KNU0URGPi/FXm2A78GAU+7uT LGrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=FdRXTEhP; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lg11-20020a170902fb8b00b0019f24ac470bsi26652132plb.559.2023.03.27.18.43.53; Mon, 27 Mar 2023 18:44:05 -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; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=FdRXTEhP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232202AbjC1BeI (ORCPT + 99 others); Mon, 27 Mar 2023 21:34:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229610AbjC1BeF (ORCPT ); Mon, 27 Mar 2023 21:34:05 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E49611BE3 for ; Mon, 27 Mar 2023 18:34:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=zQ9VeEDyCA7TnGkpi51WEjNMAth9a21cJDmTyCBeKrY=; b=FdRXTEhP4fiKtOfl2MvCCVteNH Fo3U7UTA2yZgYD3H14feKB3/xobaCEz5ViNsJPFbiOUjpOpNNt6UMx+03KbQ5u4DOJ6llKB6OZEGY 0Svg2J/UQEc+8lpJAOnZxiBr9qEffDpC/6sPwPMhM+vc7G+Fc3w4P/DP9cq/jk2QnUsBEygyY1WKu gsDk25xVJ/RohDGD0qIZRkq8X3L8P9dZFdwgHvofx4yehBGbUWmeyLefExGnX40ki3kgD9GcQKv0n jbkYkXmp5ouMUxqMJnteRWABe85ItB8HzfZPnxKh/dzeWL17oxzjzJYtY6jF+tYiegdSVjzdy0aYe LSghjNPA==; Received: from [2001:67c:370:128:c3d7:7f40:ffee:c8b6] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1pgyDl-00Cmz6-2P; Tue, 28 Mar 2023 01:33:57 +0000 Date: Tue, 28 Mar 2023 10:33:55 +0900 From: Christoph Hellwig To: Michael Kelley Cc: hch@lst.de, m.szyprowski@samsung.com, robin.murphy@arm.com, decui@microsoft.com, tiala@microsoft.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/1] swiotlb: Track and report io_tlb_used high water mark in debugfs Message-ID: References: <1679766790-24629-1-git-send-email-mikelley@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1679766790-24629-1-git-send-email-mikelley@microsoft.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Sat, Mar 25, 2023 at 10:53:10AM -0700, Michael Kelley wrote: > @@ -659,6 +663,14 @@ static int swiotlb_do_find_slots(struct device *dev, int area_index, > area->index = wrap_area_index(mem, index + nslots); > area->used += nslots; > spin_unlock_irqrestore(&area->lock, flags); > + > + new_used = atomic_long_add_return(nslots, &total_used); > + old_hiwater = atomic_long_read(&used_hiwater); > + do { > + if (new_used <= old_hiwater) > + break; > + } while (!atomic_long_try_cmpxchg(&used_hiwater, &old_hiwater, new_used)); > + > return slot_index; Hmm, so we're right in the swiotlb hot path here and add two new global atomics? > static int io_tlb_used_get(void *data, u64 *val) > { > - *val = mem_used(&io_tlb_default_mem); > + *val = (u64)atomic_long_read(&total_used); > return 0; > } > + > +static int io_tlb_hiwater_get(void *data, u64 *val) > +{ > + *val = (u64)atomic_long_read(&used_hiwater); I can't see how these casts would be needed.