All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Stephen Bates <sbates@raithlin.com>
Cc: Daniel Mentz <danielmentz@google.com>,
	logang@deltatee.com, Jonathan Corbet <corbet@lwn.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	Will Deacon <will.deacon@arm.com>,
	linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] genalloc: Make the avail variable an atomic64_t
Date: Thu, 26 Oct 2017 00:47:45 +0000 (UTC)	[thread overview]
Message-ID: <1655113933.49689.1508978865628.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <893BAB3D-6B3C-46BB-A16E-E64BF278D90E@raithlin.com>

----- On Oct 26, 2017, at 12:20 AM, Stephen Bates sbates@raithlin.com wrote:

>> I found that genalloc is very slow for large chunk sizes because
>> bitmap_find_next_zero_area has to grind through that entire bitmap.
>> Hence, I recommend avoiding genalloc for large chunk sizes.
> 
> Thanks for the feedback Daniel! We have been doing 16GiB without any noticeable
> issues.
> 
>> I'm thinking how this would behave on a 32 bit ARM platform
> 
> I don’t think people would be doing such big allocations on 32 bit (ARM
> systems). It would not make sense for them to be doing >4GB anyway.
> 
>>> --- a/lib/genalloc.c
>>> +++ b/lib/genalloc.c
>>> @@ -194,7 +194,7 @@ int gen_pool_add_virt(struct gen_pool *pool, unsigned long
>>> virt, phys_addr_t phy
>>>         chunk->phys_addr = phys;
>>>         chunk->start_addr = virt;
>>>         chunk->end_addr = virt + size - 1;
>>> -       atomic_set(&chunk->avail, size);
>>> +       atomic64_set(&chunk->avail, size);
> 
>> Isn't size defined as a size_t type which is 32 bit wide on ARM? How
>> can you ever set chunk->avail to anything larger than 2^32 - 1?
> 
> I did consider changing this type but it seems like there would never be a need
> to set this value to more than 4GiB on 32 bit systems.
> 
>>> @@ -464,7 +464,7 @@ size_t gen_pool_avail(struct gen_pool *pool)
>>>
>>>         rcu_read_lock();
>>>         list_for_each_entry_rcu(chunk, &pool->chunks, next_chunk)
>>> -               avail += atomic_read(&chunk->avail);
>>> +               avail += atomic64_read(&chunk->avail);
>>
>>avail is defined as size_t (32 bit). Aren't you going to overflow that variable?
> 
> Again, I don’t think people on 32 bit systems will be doing >4GB assignments so
> it would not be an issue.

We have atomic_long_t for that. Please use it instead. It will be
64-bit on 64-bit archs, and 32-bit on 32-bit archs, which seems to
fit your purpose here.

Thanks,

Mathieu


> 
> Stephen

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com

  reply	other threads:[~2017-10-26  0:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-25 15:32 [PATCH] genalloc: Make the avail variable an atomic64_t sbates
2017-10-25 15:47 ` Logan Gunthorpe
2017-10-25 17:55 ` Daniel Mentz
2017-10-25 18:11   ` Logan Gunthorpe
2017-10-25 22:20   ` Stephen  Bates
2017-10-26  0:47     ` Mathieu Desnoyers [this message]
2017-10-26 11:25       ` Stephen  Bates

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=1655113933.49689.1508978865628.JavaMail.zimbra@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=danielmentz@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=logang@deltatee.com \
    --cc=sbates@raithlin.com \
    --cc=will.deacon@arm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.