Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp207448lqz; Fri, 29 Mar 2024 13:42:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWloW/QGwAC17CXT8sW6r4n2AZ92UbrodJdF1LeYEisUJnk6EW28OVg0XuxAawq8/YifLZ4Jh7JY4gk5lL2tF0Q40/mkn/IgdEZxeazXQ== X-Google-Smtp-Source: AGHT+IHMmywLuTdzKk3C2v0KbgOVdcs5biwipCBa4UPR0ecL4ND/WbvXWEJIEjIQ4y5Rjxvzt1bx X-Received: by 2002:a17:90a:db96:b0:2a1:79c5:1c88 with SMTP id h22-20020a17090adb9600b002a179c51c88mr3167359pjv.1.1711744963073; Fri, 29 Mar 2024 13:42:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711744963; cv=pass; d=google.com; s=arc-20160816; b=S+bX56mj/v2fUm9x6vh12NRKWiTVgcIUnwj6j0minkrC37NDdRvfV/tJ2is3L/GBOq PW4gh91E7EG9zS/JGLUEEpECSuqVSopGql2cUFy4Ae9kDPXTpPF+ZTK7nUX41ZqX88zl nNXosw3kf/n9sCWYShT3pqIt1gnPO2u9cpW2eFz5iAo6lWqlLZBT8aUlOHL4KixctHZ2 sAPf2skdf7T6MepnpAzgynkdccqzW/fBmIHTqZtiogU99O6cUoQEfrVe2XVrOLCGQsoW IxKCo9x/K0XXJG0qb4x7HMwTiVz8KUFMCo/1WHZ+CIqsmZR2OgmynWjJICVaWOtRg1o9 XzpQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature :dkim-filter; bh=T3bq+rfTxoFcrWlHxiM/MsuE/8OiSBnZvhXgUAsFCnQ=; fh=+Hk8D+MEdELDk/3LZqEHQxEnuY49XCnSOtOXE0EmpzE=; b=PgDQUlu019f6VEtxfubs0aljmch0aobTuNgNKiIN9haAWxD8LwZZcxam4xP4VjEJs7 Gc5L/f23o1FiI/2ZSYkE7ZYmJhWKbQ+Yh2Se/7fabO9VBRQspW3ruKst54tX6F3a5pQr 5WcM7DtLtI+ZX1HWevYyVQ5cL8J/mmYHULfcxzM0+cQ2UPJv8me0OJxJKv5k66Gi6m5q dPi8PShYCdTaLx/HIPrOXuFjcW4Y2p7GM1L16vCFgYVIA5/KdTMshyStiT3dHcpjPHQL E4IaChiLda+JshUxjEtJMAJ2QFKznGMI0ZgrcE995iqi68yYbhYxWxpW4iodaYlacmQJ /doA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=XqiX32Sj; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-125399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125399-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id it6-20020a17090afb0600b0029b6b5a5b1esi4324704pjb.108.2024.03.29.13.42.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 13:42:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-125399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=XqiX32Sj; arc=pass (i=1 spf=pass spfdomain=linux.microsoft.com dkim=pass dkdomain=linux.microsoft.com dmarc=pass fromdomain=linux.microsoft.com); spf=pass (google.com: domain of linux-kernel+bounces-125399-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125399-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7DE45B23528 for ; Fri, 29 Mar 2024 20:42:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E0B3C6AFAE; Fri, 29 Mar 2024 20:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="XqiX32Sj" Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C3ACE3C08F; Fri, 29 Mar 2024 20:42:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711744952; cv=none; b=XhaK8gSGuO2O9CzBOOOzcEIjn5jY2PnW9ieLhcBwDptjDoNblQaS72BFbwoNBKvcs/9FavA0b13L+bJR7VD0fkdSjW7WzEc90Pj1A1gA8VHpS7znBDHly7mJdvpedUZeH3Y0XfMPOWA2zHOzIzcE/yy91PVE0soZmjQQinAI1jk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711744952; c=relaxed/simple; bh=hz5RR0GReCD0o+TbGpPzwpXzow8mvQnlmHPDe6BzQNU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=cDuFMISyU/0W7NAamxJut++EEeR83zlIzZH/qiyJsJdnezPQCTHk2wjeLq6Db47PjB0SJ2aCKz+TP4vUVoiDi6K2DJQWiWFuGeStNdVbfbI+WCVX4YqhhYGxNszGGGOIZ0a6HxnLuiJ+S7OJ5hg2KSP1zz+KxfUS6k9Dsj5j9Jc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=XqiX32Sj; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Received: from [100.64.65.59] (unknown [20.29.225.195]) by linux.microsoft.com (Postfix) with ESMTPSA id 0787420E6F42; Fri, 29 Mar 2024 13:42:29 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0787420E6F42 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1711744950; bh=T3bq+rfTxoFcrWlHxiM/MsuE/8OiSBnZvhXgUAsFCnQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=XqiX32SjGqD3vk/hUo4BhZDOk+DdTVyaYWF0zAdPXk7zAPwBavYyWo7D6sBZ68dFM L/TJp4duCoEIVCMuOHHW4ZCL+J6aZF4kQn9MMkQ/Rrv/qeFr0jl+jI9CJ8Ck9rFn6n NPijVBOT4MeX1n6mROxFMxLlPNRa1eBx5dJHF0DM= Message-ID: <9336949d-6fa4-457c-8d7e-9aaa5d62cbd7@linux.microsoft.com> Date: Fri, 29 Mar 2024 13:42:27 -0700 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] swiotlb: Do not set total_used to 0 in swiotlb_create_debugfs_files() To: Dexuan Cui , "hch@lst.de" , "m.szyprowski@samsung.com" , "robin.murphy@arm.com" , "zhangpeng362@huawei.com" , "iommu@lists.linux.dev" , "mhklinux@outlook.com" Cc: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" References: <20240329192809.17318-1-decui@microsoft.com> <07ed50c1-75a9-494c-8a6a-5edcc2d6f932@linux.microsoft.com> Content-Language: en-CA From: Easwar Hariharan In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/29/2024 1:30 PM, Dexuan Cui wrote: >> From: Dexuan Cui >> Sent: Friday, March 29, 2024 1:23 PM >> To: Easwar Hariharan ; hch@lst.de; >> m.szyprowski@samsung.com; robin.murphy@arm.com; >> zhangpeng362@huawei.com; iommu@lists.linux.dev; >> mhklinux@outlook.com >> Cc: linux-kernel@vger.kernel.org; stable@vger.kernel.org >> Subject: RE: [PATCH] swiotlb: Do not set total_used to 0 in >> swiotlb_create_debugfs_files() >> >>> From: Easwar Hariharan >>> Sent: Friday, March 29, 2024 12:47 PM >>> [...] >>> Sorry, I'm missing a why in this commit message. Can you say what >> happens >>> if the total_used and used_hiwater IS blindly set to 0? Is the only effect >>> the change in the readout of the swiotlb debugfs files? >>> >>> Thanks, >>> Easwar >> >> Right, when the system is not doing any I/O, the readout may >> return a huge number while it should return 0. This is the only effect. >> >> Thanks, >> Dexuan > > Let me share more details. > > kernel/dma/swiotlb.c uses inc_used_and_hiwater() and dec_used() > to do the accounting. > > The issue happens this way: > > 1. inc_used_and_hiwater() adds n to total_used. > 2. swiotlb_create_debugfs_files() sets total_used to 0. > 3. dec_used() decreases total_used by n, i.e. total_used incorrectly > becomes a negative number -n, which is a huge number since > mem_used() converts the 'long' to 'unsigned long'. > > Thanks, > Dexuan > Thanks for the detail. I only ask because the patch is marked for stable, and I was wondering if it meets the criteria. But, as you mentioned off list, two Fixes tags probably do meet the bar. Thanks, Easwar