All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manfred Spraul <manfred@colorfullife.com>
To: Davidlohr Bueso <davidlohr@hp.com>, akpm@linux-foundation.org
Cc: aswin@hp.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/5] ipc,msg: move some msgq ns code around
Date: Sat, 17 May 2014 19:57:57 +0200	[thread overview]
Message-ID: <5377A325.3030009@colorfullife.com> (raw)
In-Reply-To: <1400012857-11733-3-git-send-email-davidlohr@hp.com>

On 05/13/2014 10:27 PM, Davidlohr Bueso wrote:
> Nothing big and no logical changes, just get rid of some
> redundant function declarations. Move msg_[init/exit]_ns
> down the end of the file.
>
> Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
Signed-off-by: Manfred Spraul <manfred@colorfullife.com>

> ---
>   ipc/msg.c | 132 ++++++++++++++++++++++++++++++--------------------------------
>   1 file changed, 63 insertions(+), 69 deletions(-)
>
> diff --git a/ipc/msg.c b/ipc/msg.c
> index 5a8489b..6d33e30 100644
> --- a/ipc/msg.c
> +++ b/ipc/msg.c
> @@ -70,75 +70,6 @@ struct msg_sender {
>   
>   #define msg_ids(ns)	((ns)->ids[IPC_MSG_IDS])
>   
> -static void freeque(struct ipc_namespace *, struct kern_ipc_perm *);
> -static int newque(struct ipc_namespace *, struct ipc_params *);
> -#ifdef CONFIG_PROC_FS
> -static int sysvipc_msg_proc_show(struct seq_file *s, void *it);
> -#endif
> -
> -/*
> - * Scale msgmni with the available lowmem size: the memory dedicated to msg
> - * queues should occupy at most 1/MSG_MEM_SCALE of lowmem.
> - * Also take into account the number of nsproxies created so far.
> - * This should be done staying within the (MSGMNI , IPCMNI/nr_ipc_ns) range.
> - */
> -void recompute_msgmni(struct ipc_namespace *ns)
> -{
> -	struct sysinfo i;
> -	unsigned long allowed;
> -	int nb_ns;
> -
> -	si_meminfo(&i);
> -	allowed = (((i.totalram - i.totalhigh) / MSG_MEM_SCALE) * i.mem_unit)
> -		/ MSGMNB;
> -	nb_ns = atomic_read(&nr_ipc_ns);
> -	allowed /= nb_ns;
> -
> -	if (allowed < MSGMNI) {
> -		ns->msg_ctlmni = MSGMNI;
> -		return;
> -	}
> -
> -	if (allowed > IPCMNI / nb_ns) {
> -		ns->msg_ctlmni = IPCMNI / nb_ns;
> -		return;
> -	}
> -
> -	ns->msg_ctlmni = allowed;
> -}
> -
> -void msg_init_ns(struct ipc_namespace *ns)
> -{
> -	ns->msg_ctlmax = MSGMAX;
> -	ns->msg_ctlmnb = MSGMNB;
> -
> -	recompute_msgmni(ns);
> -
> -	atomic_set(&ns->msg_bytes, 0);
> -	atomic_set(&ns->msg_hdrs, 0);
> -	ipc_init_ids(&ns->ids[IPC_MSG_IDS]);
> -}
> -
> -#ifdef CONFIG_IPC_NS
> -void msg_exit_ns(struct ipc_namespace *ns)
> -{
> -	free_ipcs(ns, &msg_ids(ns), freeque);
> -	idr_destroy(&ns->ids[IPC_MSG_IDS].ipcs_idr);
> -}
> -#endif
> -
> -void __init msg_init(void)
> -{
> -	msg_init_ns(&init_ipc_ns);
> -
> -	printk(KERN_INFO "msgmni has been set to %d\n",
> -		init_ipc_ns.msg_ctlmni);
> -
> -	ipc_init_proc_interface("sysvipc/msg",
> -				"       key      msqid perms      cbytes       qnum lspid lrpid   uid   gid  cuid  cgid      stime      rtime      ctime\n",
> -				IPC_MSG_IDS, sysvipc_msg_proc_show);
> -}
> -
>   static inline struct msg_queue *msq_obtain_object(struct ipc_namespace *ns, int id)
>   {
>   	struct kern_ipc_perm *ipcp = ipc_obtain_object(&msg_ids(ns), id);
> @@ -1054,6 +985,57 @@ SYSCALL_DEFINE5(msgrcv, int, msqid, struct msgbuf __user *, msgp, size_t, msgsz,
>   	return do_msgrcv(msqid, msgp, msgsz, msgtyp, msgflg, do_msg_fill);
>   }
>   
> +/*
> + * Scale msgmni with the available lowmem size: the memory dedicated to msg
> + * queues should occupy at most 1/MSG_MEM_SCALE of lowmem.
> + * Also take into account the number of nsproxies created so far.
> + * This should be done staying within the (MSGMNI , IPCMNI/nr_ipc_ns) range.
> + */
> +void recompute_msgmni(struct ipc_namespace *ns)
> +{
> +	struct sysinfo i;
> +	unsigned long allowed;
> +	int nb_ns;
> +
> +	si_meminfo(&i);
> +	allowed = (((i.totalram - i.totalhigh) / MSG_MEM_SCALE) * i.mem_unit)
> +		/ MSGMNB;
> +	nb_ns = atomic_read(&nr_ipc_ns);
> +	allowed /= nb_ns;
> +
> +	if (allowed < MSGMNI) {
> +		ns->msg_ctlmni = MSGMNI;
> +		return;
> +	}
> +
> +	if (allowed > IPCMNI / nb_ns) {
> +		ns->msg_ctlmni = IPCMNI / nb_ns;
> +		return;
> +	}
> +
> +	ns->msg_ctlmni = allowed;
> +}
> +
> +void msg_init_ns(struct ipc_namespace *ns)
> +{
> +	ns->msg_ctlmax = MSGMAX;
> +	ns->msg_ctlmnb = MSGMNB;
> +
> +	recompute_msgmni(ns);
> +
> +	atomic_set(&ns->msg_bytes, 0);
> +	atomic_set(&ns->msg_hdrs, 0);
> +	ipc_init_ids(&ns->ids[IPC_MSG_IDS]);
> +}
> +
> +#ifdef CONFIG_IPC_NS
> +void msg_exit_ns(struct ipc_namespace *ns)
> +{
> +	free_ipcs(ns, &msg_ids(ns), freeque);
> +	idr_destroy(&ns->ids[IPC_MSG_IDS].ipcs_idr);
> +}
> +#endif
> +
>   #ifdef CONFIG_PROC_FS
>   static int sysvipc_msg_proc_show(struct seq_file *s, void *it)
>   {
> @@ -1078,3 +1060,15 @@ static int sysvipc_msg_proc_show(struct seq_file *s, void *it)
>   			msq->q_ctime);
>   }
>   #endif
> +
> +void __init msg_init(void)
> +{
> +	msg_init_ns(&init_ipc_ns);
> +
> +	printk(KERN_INFO "msgmni has been set to %d\n",
> +		init_ipc_ns.msg_ctlmni);
> +
> +	ipc_init_proc_interface("sysvipc/msg",
> +				"       key      msqid perms      cbytes       qnum lspid lrpid   uid   gid  cuid  cgid      stime      rtime      ctime\n",
> +				IPC_MSG_IDS, sysvipc_msg_proc_show);
> +}


  reply	other threads:[~2014-05-17 17:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 20:27 [PATCH -next 0/5] ipc,msg: fixes and updates Davidlohr Bueso
2014-05-13 20:27 ` [PATCH 1/5] ipc,msg: use current->state helpers Davidlohr Bueso
2014-05-17 17:55   ` Manfred Spraul
2014-05-13 20:27 ` [PATCH 2/5] ipc,msg: move some msgq ns code around Davidlohr Bueso
2014-05-17 17:57   ` Manfred Spraul [this message]
2014-05-13 20:27 ` [PATCH 3/5] ipc,msg: always respect MSG_NOERROR Davidlohr Bueso
2014-05-18  5:53   ` Manfred Spraul
2014-05-18 18:01     ` Davidlohr Bueso
2014-05-19 18:01       ` Manfred Spraul
2014-05-13 20:27 ` [PATCH 4/5] ipc,msg: document volatile r_msg Davidlohr Bueso
2014-05-18  6:08   ` Manfred Spraul
2014-05-13 20:27 ` [PATCH 5/5] ipc,msg: loosen check for full queue Davidlohr Bueso
2014-05-14 18:00   ` Manfred Spraul
2014-05-14 19:50     ` Davidlohr Bueso
2014-05-15  4:20       ` Manfred Spraul
2014-05-15 15:46         ` Davidlohr Bueso
2014-05-16 12:47           ` Michael Kerrisk (man-pages)
2014-05-18 18:16             ` Davidlohr Bueso

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=5377A325.3030009@colorfullife.com \
    --to=manfred@colorfullife.com \
    --cc=akpm@linux-foundation.org \
    --cc=aswin@hp.com \
    --cc=davidlohr@hp.com \
    --cc=linux-kernel@vger.kernel.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 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.