public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Or Gerlitz <ogerlitz-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
To: Roland Dreier <roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Jack Morgenstein
	<jackm-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
Cc: Yishai Hadas <yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
Subject: possible bug when scaling MTT table size with system ram
Date: Sun, 20 May 2012 15:04:02 +0300	[thread overview]
Message-ID: <4FB8DDB2.8050506@mellanox.com> (raw)

Roland,

Yishai Hadas from Mellanox noted that commit db5a7a65c05 "mlx4_core: 
Scale size of MTT table
with system RAM" seems to introduce a bug, where if request->num_mtt 
becomes 2^25 or higher

> +       /*
> +        * We want to scale the number of MTTs with the size of the
> +        * system memory, since it makes sense to register a lot of
> +        * memory on a system with a lot of memory.  As a heuristic,
> +        * make sure we have enough MTTs to cover twice the system
> +        * memory (with PAGE_SIZE entries).
> +        *
> +        * This number has to be a power of two and fit into 32 bits
> +        * due to device limitations, so cap this at 2^31 as well.
> +        * That limits us to 8TB of memory registration per HCA with
> +        * 4KB pages, which is probably OK for the next few months.
> +        */
> +       si_meminfo(&si);
> +       request->num_mtt =
> +               roundup_pow_of_two(max_t(unsigned, request->num_mtt,
> +                                        min(1UL << 31,
> +                                            si.totalram >> 
> (log_mtts_per_seg - 1))));
> +


we are somehow getting into a situation where mlx4_buddy_init needs to 
allocate > 128KB using
kmalloc, which is impossible... he was suggesting to replace 
kmalloc/kfree with vmalloc/vfree
(see below). What's your thinking here? should we go to get_free_pages? 
limit by 2^25? something else?


Or.

> --- a/drivers/net/ethernet/mellanox/mlx4/mr.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/mr.c
> @@ -129,7 +129,7 @@ static int mlx4_buddy_init(struct mlx4_buddy 
> *buddy, int max_order)
>
>         for (i = 0; i <= buddy->max_order; ++i) {
>                 s = BITS_TO_LONGS(1 << (buddy->max_order - i));
> -               buddy->bits[i] = kmalloc(s * sizeof (long), GFP_KERNEL);
> +               buddy->bits[i] = vmalloc(s * sizeof(long));
>                 if (!buddy->bits[i])
>                         goto err_out_free;
>                 bitmap_zero(buddy->bits[i], 1 << (buddy->max_order - i));
> @@ -142,7 +142,7 @@ static int mlx4_buddy_init(struct mlx4_buddy 
> *buddy, int max_order)
>
>  err_out_free:
>         for (i = 0; i <= buddy->max_order; ++i)
> -               kfree(buddy->bits[i]);
> +               vfree(buddy->bits[i]);
>
>  err_out:
>         kfree(buddy->bits);
> @@ -156,7 +156,7 @@ static void mlx4_buddy_cleanup(struct mlx4_buddy 
> *buddy)
>         int i;
>
>         for (i = 0; i <= buddy->max_order; ++i)
> -               kfree(buddy->bits[i]);
> +               vfree(buddy->bits[i]);
>
>         kfree(buddy->bits);
>         kfree(buddy->num_free);

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2012-05-20 12:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-20 12:04 Or Gerlitz [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-05-20 12:03 possible bug when scaling MTT table size with system ram Or Gerlitz

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=4FB8DDB2.8050506@mellanox.com \
    --to=ogerlitz-vpraknaxozvwk0htik3j/w@public.gmane.org \
    --cc=jackm-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=roland-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=yishaih-VPRAkNaXOzVWk0Htik3J/w@public.gmane.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