Linux IOMMU Development
 help / color / mirror / Atom feed
From: Steven Sistare <steven.sistare@oracle.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: iommu@lists.linux.dev, Kevin Tian <kevin.tian@intel.com>,
	Nicolin Chen <nicolinc@nvidia.com>
Subject: Re: [PATCH V3 8/9] iommufd: optimize file mapping
Date: Thu, 17 Oct 2024 13:02:14 -0400	[thread overview]
Message-ID: <6fdad0c2-8b6a-433e-9405-016aaee40413@oracle.com> (raw)
In-Reply-To: <20241016130001.GI3559746@nvidia.com>

On 10/16/2024 9:00 AM, Jason Gunthorpe wrote:
> On Fri, Oct 04, 2024 at 11:48:19AM -0700, Steve Sistare wrote:
> 
>> @@ -347,25 +347,41 @@ static void batch_destroy(struct pfn_batch *batch, void *backup)
>>   		kfree(batch->pfns);
>>   }
>>   
>> -/* true if the pfn was added, false otherwise */
>> -static bool batch_add_pfn(struct pfn_batch *batch, unsigned long pfn)
>> +/* returns the number of pfn's added */
>> +static int batch_add_pfn_num(struct pfn_batch *batch, unsigned long pfn,
>> +			     unsigned long nr)
> 
> This return type is truncating unsigned longs to int..

Thanks, will fix.

>> @@ -623,6 +639,67 @@ static void batch_from_pages(struct pfn_batch *batch, struct page **pages,
>>   			break;
>>   }
>>   
>> +static void batch_from_folios(struct pfn_batch *batch, struct folio **folios,
>> +			      size_t npages)
>> +{
>> +	struct folio **end = folios + npages;
>> +
>> +	for (; folios != end; folios++)
>> +		if (!batch_add_pfn(batch, page_to_pfn(&folios[0]->page)))
>> +			break;
> 
> This function is really weird, why would we have a function adding
> only the first page of each item in a list of folios?

It is only called when we know that the number of pages in all folios is 1
(user->ufolios_huge is false).

>> +static void batch_from_folios_huge(struct pfn_batch *batch,
>> +				   struct folio ***folios_p,
>> +				   unsigned long *offset_p,
>> +				   unsigned long npages)
>> +{
>> +	unsigned long nr, n, pfn, i = 0;
>> +	struct folio *folio, **folios = *folios_p;
>> +	unsigned long offset = *offset_p;
> 
> Let's make more use of scope local values please (put folio, pfn, etc
> in side the narrowest loop scope) 

OK.  Some like this, some do not, now I know your preference.
I personally like to use local scope and initializers, but dislike when
cstyle it forces me to add a blank line after the declarations which disrupts
the flow/use of some quantity, eg:
   {
     long pfn = foo();

     bar(pfn);
   }

> and the style in iommufd avoids more
> than one variable per declaration

OK, I had not realized that.

- Steve

> 
> I would like to see this patch when it is applied but I can't apply
> it..

I will send you my patched version of pages.c off list.

- Steve



  parent reply	other threads:[~2024-10-17 17:02 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-04 18:48 [PATCH V3 0/9] iommu_ioas_map_file Steve Sistare
2024-10-04 18:48 ` [PATCH V3 1/9] mm/gup: folio_add_pins Steve Sistare
2024-10-04 18:52   ` Steven Sistare
2024-10-04 20:20     ` David Hildenbrand
2024-10-16 12:17   ` Jason Gunthorpe
2024-10-04 18:48 ` [PATCH V3 2/9] iommufd: rename uptr in iopt_alloc_iova Steve Sistare
2024-10-04 18:48 ` [PATCH V3 3/9] iommufd: generalize iopt_pages address Steve Sistare
2024-10-04 18:48 ` [PATCH V3 4/9] iommufd: pfn reader for file mappings Steve Sistare
2024-10-16 12:37   ` Jason Gunthorpe
2024-10-17 17:01     ` Steven Sistare
2024-10-17 19:20       ` Jason Gunthorpe
2024-10-04 18:48 ` [PATCH V3 5/9] iommufd: IOMMU_IOAS_MAP_FILE Steve Sistare
2024-10-16 12:41   ` Jason Gunthorpe
2024-10-17 17:00     ` Steven Sistare
2024-10-17 19:20       ` Jason Gunthorpe
2024-10-04 18:48 ` [PATCH V3 6/9] iommufd: file mappings for mdev Steve Sistare
2024-10-04 18:48 ` [PATCH V3 7/9] iommufd: pfn reader local variables Steve Sistare
2024-10-16 12:42   ` Jason Gunthorpe
2024-10-04 18:48 ` [PATCH V3 8/9] iommufd: optimize file mapping Steve Sistare
2024-10-16 13:00   ` Jason Gunthorpe
2024-10-16 13:09     ` Steven Sistare
2024-10-16 13:21       ` Jason Gunthorpe
2024-10-17 17:02     ` Steven Sistare [this message]
2024-10-17 19:24       ` Jason Gunthorpe
2024-10-17 19:37         ` Steven Sistare
2024-10-18  0:10           ` Jason Gunthorpe
2024-10-18 14:34             ` Steven Sistare
2024-10-18 16:04               ` Jason Gunthorpe
2024-10-18 17:54                 ` Steven Sistare
2024-10-18 17:59                   ` Jason Gunthorpe
2024-10-18 18:10                     ` Steven Sistare
2024-10-18 23:10                       ` Jason Gunthorpe
2024-10-21 14:06                         ` Steven Sistare
2024-10-21 14:29                           ` Steven Sistare
2024-10-21 16:11                             ` Jason Gunthorpe
2024-10-21 17:29                               ` Steven Sistare
2024-10-21 16:10                           ` Jason Gunthorpe
2024-10-04 18:48 ` [PATCH V3 9/9] iommufd: map file selftest Steve Sistare
2024-10-16 12:23 ` [PATCH V3 0/9] iommu_ioas_map_file Jason Gunthorpe

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=6fdad0c2-8b6a-433e-9405-016aaee40413@oracle.com \
    --to=steven.sistare@oracle.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=kevin.tian@intel.com \
    --cc=nicolinc@nvidia.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