public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Easwar Hariharan <eahariha@linux.microsoft.com>
To: Dexuan Cui <decui@microsoft.com>, "hch@lst.de" <hch@lst.de>,
	"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
	"robin.murphy@arm.com" <robin.murphy@arm.com>,
	"zhangpeng362@huawei.com" <zhangpeng362@huawei.com>,
	"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
	"mhklinux@outlook.com" <mhklinux@outlook.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] swiotlb: Do not set total_used to 0 in swiotlb_create_debugfs_files()
Date: Fri, 29 Mar 2024 13:42:27 -0700	[thread overview]
Message-ID: <9336949d-6fa4-457c-8d7e-9aaa5d62cbd7@linux.microsoft.com> (raw)
In-Reply-To: <CY5PR21MB3759C7C9F4637F6D157635A1BF3A2@CY5PR21MB3759.namprd21.prod.outlook.com>

On 3/29/2024 1:30 PM, Dexuan Cui wrote:
>> From: Dexuan Cui
>> Sent: Friday, March 29, 2024 1:23 PM
>> To: Easwar Hariharan <eahariha@linux.microsoft.com>; 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 <eahariha@linux.microsoft.com>
>>> 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

  reply	other threads:[~2024-03-29 20:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-29 19:28 [PATCH] swiotlb: Do not set total_used to 0 in swiotlb_create_debugfs_files() Dexuan Cui
2024-03-29 19:46 ` Easwar Hariharan
2024-03-29 20:23   ` Dexuan Cui
2024-03-29 20:30     ` Dexuan Cui
2024-03-29 20:42       ` Easwar Hariharan [this message]
2024-03-29 22:59 ` Michael Kelley
2024-03-30  1:19 ` zhangpeng (AS)
2024-03-30  8:25 ` Petr Tesařík
2024-04-02 15:10 ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9336949d-6fa4-457c-8d7e-9aaa5d62cbd7@linux.microsoft.com \
    --to=eahariha@linux.microsoft.com \
    --cc=decui@microsoft.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mhklinux@outlook.com \
    --cc=robin.murphy@arm.com \
    --cc=stable@vger.kernel.org \
    --cc=zhangpeng362@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox