lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 20 Jul 2009 22:49:57 -0700
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Philipp Reisner <philipp.reisner@...bit.com>
Cc:	linux-kernel@...r.kernel.org, Jens Axboe <jens.axboe@...cle.com>,
	Greg KH <gregkh@...e.de>, Neil Brown <neilb@...e.de>,
	James Bottomley <James.Bottomley@...senPartnership.com>,
	Sam Ravnborg <sam@...nborg.org>, Dave Jones <davej@...hat.com>,
	Nikanth Karthikesan <knikanth@...e.de>,
	"Lars Marowsky-Bree" <lmb@...e.de>,
	"Nicholas A. Bellinger" <nab@...ux-iscsi.org>,
	Kyle Moffett <kyle@...fetthome.net>,
	Bart Van Assche <bart.vanassche@...il.com>,
	Christoph Hellwig <hch@...radead.org>,
	drbd-dev@...ts.linbit.com,
	Lars Ellenberg <lars.ellenberg@...bit.com>
Subject: Re: [PATCH 04/16] drbd: dirty bitmap

On Mon,  6 Jul 2009 17:39:23 +0200 Philipp Reisner <philipp.reisner@...bit.com> wrote:

> DRBD maintains a dirty bitmap in case it has to run without peer node or
> without local disk. Writes to the on disk dirty bitmap are minimized by the
> activity log (=AL). Each time an extent is evicted from the AL the part of
> the bitmap no longer covered by the AL is written to disk.
> 
> ...
>
> +static struct page **bm_realloc_pages(struct drbd_bitmap *b, unsigned long want)
> +{
> +	struct page **old_pages = b->bm_pages;
> +	struct page **new_pages, *page;
> +	unsigned int i, bytes, vmalloced = 0;
> +	unsigned long have = b->bm_number_of_pages;
> +
> +	BUG_ON(have == 0 && old_pages != NULL);
> +	BUG_ON(have != 0 && old_pages == NULL);
> +
> +	if (have == want)
> +		return old_pages;
> +
> +	/* Trying kmalloc first, falling back to vmalloc.
> +	 * GFP_KERNEL is ok, as this is done when a lower level disk is
> +	 * "attached" to the drbd.  Context is receiver thread or cqueue
> +	 * thread.  As we have no disk yet, we are not in the IO path,
> +	 * not even the IO path of the peer. */
> +	bytes = sizeof(struct page *)*want;
> +	new_pages = kmalloc(bytes, GFP_KERNEL);
> +	if (!new_pages) {
> +		new_pages = vmalloc(bytes);
> +		if (!new_pages)
> +			return NULL;
> +		vmalloced = 1;
> +	}
> +
> +	memset(new_pages, 0, bytes);
> +	if (want >= have) {
> +		for (i = 0; i < have; i++)
> +			new_pages[i] = old_pages[i];
> +		for (; i < want; i++) {
> +			page = alloc_page(GFP_HIGHUSER);
> +			if (!page) {
> +				bm_free_pages(new_pages + have, i - have);
> +				bm_vk_free(new_pages, vmalloced);
> +				return NULL;
> +			}
> +			new_pages[i] = page;
> +		}
> +	} else {
> +		for (i = 0; i < want; i++)
> +			new_pages[i] = old_pages[i];
> +		/* NOT HERE, we are outside the spinlock!
> +		bm_free_pages(old_pages + want, have - want);
> +		*/
> +	}
> +
> +	if (vmalloced)
> +		set_bit(BM_P_VMALLOCED, &b->bm_flags);
> +	else
> +		clear_bit(BM_P_VMALLOCED, &b->bm_flags);
> +
> +	return new_pages;
> +}

The vmalloc is always troublesome.

It's a pretty commonly-occurring pattern and I've been suggesting that
we implement a generic dynamic-array facility so that those callsites
which wish to do huge contiguous allocations need no longer do that.

Please take a look at this thread: http://lkml.org/lkml/2009/7/2/464
and let's see if there's any useful commonality here.  I think there
is...

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ