dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: David Airlie <airlied@linux.ie>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 2/2] drm: i915: Switch to bitmap_zalloc()
Date: Mon, 4 Mar 2019 11:54:46 +0200	[thread overview]
Message-ID: <20190304095446.GQ9224@smile.fi.intel.com> (raw)
In-Reply-To: <155169249395.14887.7355269908702960349@skylake-alporthouse-com>

On Mon, Mar 04, 2019 at 09:41:34AM +0000, Chris Wilson wrote:
> Quoting Andy Shevchenko (2019-03-04 09:29:08)
> > Switch to bitmap_zalloc() to show clearly what we are allocating.
> > Besides that it returns pointer of bitmap type instead of opaque void *.
> 
> Which is confusing; since we explicitly want unsigned longs, not some
> amorphous bitmap type.

Why? You use it as a bitmap anyway since you are telling below you are using
bit ops like set/clear_bit.

> >         if (obj->bit_17 == NULL) {
> > -               obj->bit_17 = kcalloc(BITS_TO_LONGS(page_count),
> > -                                     sizeof(long), GFP_KERNEL);
> > +               obj->bit_17 = bitmap_zalloc(page_count, GFP_KERNEL);
> 
> That feels a bit more of an overreach, as we just use bitops and never
> actually use the bitmap iface.

bitops are _luckily_ part of bitmap iface. bitmap iface has been evolved
specifically the way the existing ops will work on it w/o any change.

> Simply because it kills BITS_TO_LONGS(), even though I do not see why
> the bitmap_[z]alloc and bitmap_free are not inlines...

Because of circular dependencies (hell) in the headers.

> And for this is not the overflow protection of kcalloc silly? We start
> with a large value, factorise it, then check that the two factors do not
> overflow? If it were to overflow, it would overflow in the
> BITS_TO_LONGS() itself.

This just a simple API change w/o functional changes.

> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Thank you.


-- 
With Best Regards,
Andy Shevchenko


_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2019-03-04  9:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-04  9:29 [PATCH v2 1/2] drm/selftests/mm: Switch to bitmap_zalloc() Andy Shevchenko
2019-03-04  9:29 ` [PATCH v2 2/2] drm: i915: " Andy Shevchenko
2019-03-04  9:41   ` Chris Wilson
2019-03-04  9:54     ` Andy Shevchenko [this message]
2019-03-04 10:08       ` Chris Wilson
2019-03-04  9:43 ` [PATCH v2 1/2] drm/selftests/mm: " Chris Wilson
2019-03-20 17:36   ` Chris Wilson

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=20190304095446.GQ9224@smile.fi.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=airlied@linux.ie \
    --cc=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /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;
as well as URLs for NNTP newsgroup(s).