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:	Thu, 3 May 2012 12:21:05 +0300
From:	Dan Carpenter <dan.carpenter@...cle.com>
To:	Doug Ledford <dledford@...hat.com>
Cc:	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
	sfr@...b.auug.org.au
Subject: Re: [Patch 1/4] ipc/mqueue: improve performance of send/recv

On Tue, May 01, 2012 at 01:50:52PM -0400, Doug Ledford wrote:
> @@ -150,16 +241,25 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
>  			info->attr.mq_maxmsg = attr->mq_maxmsg;
>  			info->attr.mq_msgsize = attr->mq_msgsize;
>  		}
> -		mq_msg_tblsz = info->attr.mq_maxmsg * sizeof(struct msg_msg *);
> -		if (mq_msg_tblsz > PAGE_SIZE)
> -			info->messages = vmalloc(mq_msg_tblsz);
> -		else
> -			info->messages = kmalloc(mq_msg_tblsz, GFP_KERNEL);
> -		if (!info->messages)
> -			goto out_inode;
> +		/*
> +		 * We used to allocate a static array of pointers and account
> +		 * the size of that array as well as one msg_msg struct per
> +		 * possible message into the queue size. That's no longer
> +		 * accurate as the queue is now an rbtree and will grow and
> +		 * shrink depending on usage patterns.  We can, however, still
> +		 * account one msg_msg struct per message, but the nodes are
> +		 * allocated depending on priority usage, and most programs
> +		 * only use one, or a handful, of priorities.  However, since
> +		 * this is pinned memory, we need to assume worst case, so
> +		 * that means the min(mq_maxmsg, max_priorities) * struct
> +		 * posix_msg_tree_node.
> +		 */
> +		mq_treesize = info->attr.mq_maxmsg * sizeof(struct msg_msg) +
> +			min_t(unsigned int, info->attr.mq_maxmsg, MQ_PRIO_MAX) *
> +			sizeof(struct posix_msg_tree_node);

"info->attr.mq_maxmsg" is a long, but the min_t() truncates it to an
unsigned int.  I'm not familiar with this code so I don't know if
that's a problem...

We do the same thing in mqueue_evict_inode() and mq_attr_ok().

regards,
dan carpenter

--
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