Skip to contentSkip to conversation

updated ipc lock patch

PATCH New Rusty Russell 5 participants 11 messages Oct 28, 2002 – Oct 29, 2002 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

In message <[email protected]> you write:

Quoted 6 lines · Rusty Russell
Quoted 3 lines

You can't do that. It's the price you pay. It's nonsensical to fail to destroy an shm or sem.

Ironic, but not nonsensical.

Yes, nonsensical. Firstly, it's in violation of the standard to fail IPC_RMID under random circumstances. Secondly, failing to clean up is an unhandlable error, since you're quite possible in the failure path of the code already. This is a well known issue.

Quoted 6 lines
Quoted 5 lines

Using a mempool is putting your head in the sand, because it's use is not bounded. Might as well just ignore kmalloc failures and leak memory, which is *really* dumb, because if we get killed by the oom-killer because we're out of memory, and that results in IPC trying to free.

Quoted 6 lines

Bounded in what sense? The mempool is dedicated to ipc freeing, it's not being drawn on by other kinds of use. In the OOM-kill case of actually getting down to using the reserved pool, each reserved item will be returned when RCU (and, in the vfree case, the additional scheduled work) has done with it. Unbounded in that we cannot say how many milliseconds that will take, but so what?

Two oom kills. Three oom kills. Four oom kills. Where's the bound here?

Our allocator behavior for GFP_KERNEL has changed several times. Are you sure that it won't *ever* fail under other circomstances?

Quoted 3 lines

Okay (I expect, didn't review it) for just the ids arrays, but too much memory waste if we have to allocate for each msq, sema, shm: if there's a better solution available. mempool looks better to us.

It's a hacky, fragile and incorrect solution. It's completely tasteless.

There are *three* things this patch does, and it's not clear which ones helped the dbt1 benchmark (and I can't find the source). But let's assume they're all good optimizations (*cough*).

In order to save 12 bytes, you've added dozens of lines of subtle, fragile, incorrect code. You honestly think this is a worthwhile tradeoff?

Quoted 5 lines
Quoted 1 line

Hope that helps,

Not yet. You seem to have had a bad experience with something like this (the mempools or the RCU or the combination), and you're warning us away without actually telling us what you found.

I *wrote* the RCU interface (though the implementation in 2.5 isn't mine). I thought it was pretty clear how it was supposed to be used. Obviously, I was wrong.

Quoted 2 lines

I suspect that whatever it was that you found, is not relevant to this IPC case.

Clear code vs. bad code? Definitely relevent here.

Patch below is against Mingming's mm4 release. Compiles, untested. Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

Commentry: There are several cases where ipc_alloc is *always* followed by ipc_free, so the extra allocation is gratuitous, but these are temporary allocations and the extra size is not critical.

include/linux/msg.h +3 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal working-2.5.44-mm4-ipc-rcu/include/linux/msg.h working-2.5.44-mm4-ipc-rcu-fix/include/linux/msg.h
@@ -2,6 +2,7 @@
 #define _LINUX_MSG_H
 
 #include <linux/ipc.h>
+#include <linux/rcupdate.h>
 
 /* ipcs ctl commands */
 #define MSG_STAT 11
@@ -90,6 +91,8 @@ struct msg_queue {
 	struct list_head q_messages;
 	struct list_head q_receivers;
 	struct list_head q_senders;
+
+	struct rcu_head q_free;		/* Used to free this via rcu */
 };
 
 asmlinkage long sys_msgget (key_t key, int msgflg);
include/linux/sem.h +2 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal working-2.5.44-mm4-ipc-rcu/include/linux/sem.h working-2.5.44-mm4-ipc-rcu-fix/include/linux/sem.h
@@ -2,6 +2,7 @@
 #define _LINUX_SEM_H
 
 #include <linux/ipc.h>
+#include <linux/rcupdate.h>
 
 /* semop flags */
 #define SEM_UNDO        0x1000  /* undo the operation on exit */
@@ -94,6 +95,7 @@ struct sem_array {
 	struct sem_queue	**sem_pending_last; /* last pending operation */
 	struct sem_undo		*undo;		/* undo requests on this array */
 	unsigned long		sem_nsems;	/* no. of semaphores in array */
+	struct rcu_head		sem_free;	/* used to rcu free array. */
 };
 
 /* One queue for each sleeping process in the system. */
ipc/util.c +51 -35

120 lines not on this page · raw message

#2 lore raw

You may prefer to skip the history and goto Your_patch;

Quoted 11 lines · Rusty Russell

In message <[email protected]> you write:

Quoted 9 lines · Rusty Russell
Quoted 3 lines

You can't do that. It's the price you pay. It's nonsensical to fail to destroy an shm or sem.

Ironic, but not nonsensical: remember, this would only happen (if we abandoned the mempool method and) the task trying to free is itself being OOM-killed - sometimes, OOM-killing will kill the very task that might have gone on to free even more memory, just a sad fact.

(Since you're bringing our discussion to linux-kernel, I've restored the full paragraph of my side of the argument above.)

Quoted 4 lines

Yes, nonsensical. Firstly, it's in violation of the standard to fail IPC_RMID under random circumstances. Secondly, failing to clean up is an unhandlable error, since you're quite possible in the failure path of the code already. This is a well known issue.

The task which would have failed was being OOM-killed: it's not even going to get back to userspace. It might have been OOM-killed just before it tried to IPC_RMID, but it happened during, that's all. I think OOM-killing lies, shall we say, outside the standard?

But that's all irrelevant: we (Andrew tidied patch by Mingming following recommendation by me of solution by Andrew) added the mempool so that it will surely succeed, as you insisted, even if OOM-kill intervenes at the worst moment.

Quoted 13 lines
Quoted 6 lines
Quoted 5 lines

Using a mempool is putting your head in the sand, because it's use is not bounded. Might as well just ignore kmalloc failures and leak memory, which is *really* dumb, because if we get killed by the oom-killer because we're out of memory, and that results in IPC trying to free.

Quoted 6 lines

Bounded in what sense? The mempool is dedicated to ipc freeing, it's not being drawn on by other kinds of use. In the OOM-kill case of actually getting down to using the reserved pool, each reserved item will be returned when RCU (and, in the vfree case, the additional scheduled work) has done with it. Unbounded in that we cannot say how many milliseconds that will take, but so what?

Quoted 2 lines

Two oom kills. Three oom kills. Four oom kills. Where's the bound here?

No bound to the number of possible OOM kills, but what problem is that? I got excited for a few minutes when I thought you were saying that the task being OOM-killed would exit holding on to its mempool buffer. But that's not so, is it? We'd have wider, more serious resource problems with OOM kills if that were so.

Quoted 2 lines

Our allocator behavior for GFP_KERNEL has changed several times. Are you sure that it won't *ever* fail under other circomstances?

Well, I'll be surprised if we change kmalloc(GFP_KERNEL) to fail for reasons other than memory shortage ("insufficient privilege"? hmm, we'd change the names before that); though how hard it tries to decide if there's really a memory shortage certainly changes from one kernel to another. But so long as it doesn't fail very often in normal circumstances, it's okay: the reserved mempool buffers back it up.

Quoted 6 lines
Quoted 3 lines

Okay (I expect, didn't review it) for just the ids arrays, but too much memory waste if we have to allocate for each msq, sema, shm: if there's a better solution available. mempool looks better to us.

It's a hacky, fragile and incorrect solution. It's completely tasteless.

I guess it's a step forward that you haven't called it senseless. Hacky, tasteless? Maybe, depends on your taste. I'm inclined to counter that it's _fashionable_, which holds about as much weight. But fragile, incorrect? You've repeatedly failed to argue that.

Quoted 3 lines

In order to save 12 bytes, you've added dozens of lines of subtle, fragile, incorrect code. You honestly think this is a worthwhile tradeoff?

I thought mempool was the best way to go, to avoid wasting 80 bytes per msq, sema, shmseg - I thought it would get ugly (hacky, tasteless) to avoid the struct work overhead in some cases and not others.

Your_patch shows that it need not be ugly, and reduces the normal waste to 16 bytes per msq, sema, shmseg. These are not struct pages, that amount will often be wasted by cacheline alignment too, so I'm not going to get into a fight over it.

I think your patch looks quite nice - apart from the subtle hacky fragile tasteless void *data[0]; but if something like that is necessary, I'm sure someone can come up with a better there.

If Andrew or Mingming likes it and wants to replace the mempool solution by yours, I'm not going to object (but if that is done, remove struct rcu_ipc_free from ipc/util.h, and move its includes of rcupdate.h and workqueue.h to ipc/util.c). If they prefer the mempool method, that's fine with me too.

But I wish you'd introduced your patch as "Here, I think this is a nicer way of doing it, and doesn't waste as much as you thought:
you don't have to bother with a mempool this way" instead of getting so mysteriously upset about it, implying some idiot failure in the mempool method which you've not yet revealed to us.

Hugh

#3 lore raw

In message <[email protected]> you
write:

Quoted 2 lines

(Since you're bringing our discussion to linux-kernel, I've restored the full paragraph of my side of the argument above.)

Hi Hugh,

Thanks for your complete reply. I thought it was my fault
that it fell off lkml, and "corrected" it. Sorry about that.

Quoted 4 lines
Quoted 2 lines

Two oom kills. Three oom kills. Four oom kills. Where's the bound here?

No bound to the number of possible OOM kills, but what problem is that?

Sorry, I'm obviously not making myself clear, since I've said this three times now.

1) The memory is required for one whole RCU period (whether from kmalloc or the mempool). This can be an almost arbitrarily long time (I've seen it take a good fraction of a second).

2) This is a problem, because other tasks could be OOM killed during that period, and could also try to use this mempool.

3) So, the size of the mempool which guarantees there will be enough? It's equal to the number of things you might free, which means you might as well allocate them together.

This is the correctness problem with the mempool IPC implementation.

Quoted 9 lines
Quoted 2 lines

Our allocator behavior for GFP_KERNEL has changed several times. Are you sure that it won't *ever* fail under other circomstances?

Well, I'll be surprised if we change kmalloc(GFP_KERNEL) to fail for reasons other than memory shortage ("insufficient privilege"? hmm, we'd change the names before that); though how hard it tries to decide if there's really a memory shortage certainly changes from one kernel to another. But so long as it doesn't fail very often in normal circumstances, it's okay: the reserved mempool buffers back it up.

Once again, if ever returns NULL other than for tasks being OOM killed, the problem gets wider.

It would be reasonable for the page allocator one day to say "hmm, at the rate kswapd is going, it's going to take > 1 minute to fill this allocation. Let's fail it immediately instead".

This is the fragility problem with the mempool IPC implementation: you are relying on the kmalloc implementation details which you are explicitly not allowed to do (see previous "should kmalloc fail?" threads).

Quoted 4 lines

Your_patch shows that it need not be ugly, and reduces the normal waste to 16 bytes per msq, sema, shmseg. These are not struct pages, that amount will often be wasted by cacheline alignment too, so I'm not going to get into a fight over it.

It could be reduced to 12 bytes by cutting out the "arg", and 8 bytes by making it a single linked list. I've posted this separately.

Quoted 3 lines

I think your patch looks quite nice - apart from the subtle hacky fragile tasteless void *data[0]; but if something like that is necessary, I'm sure someone can come up with a better there.

Yes, it's tasteless, but not fragile. Skipping it would be fragile (it's unneccessary since struct rcu_head has a pointer in it).

I'm not sure that the alternative is nicer, either, though 8(

Quoted 5 lines

But I wish you'd introduced your patch as "Here, I think this is a nicer way of doing it, and doesn't waste as much as you thought:
you don't have to bother with a mempool this way" instead of getting so mysteriously upset about it, implying some idiot failure in the mempool method which you've not yet revealed to us.

You're right. This took far more time than simply producing the patch myself would have taken.

But despite that, I prefer to take the un-Viro-like approach of believing that my fellow programmers cleverer than I am, and hence require only a few subtle pointers when I manage to spot errors.

Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#4 lore raw

RFC PATCH 1/1 ipc rcu alloc/free patch - mm6

Andrew, Rusty,

Here is the patch which addresses RCU alloc problem araised by Rusty. It replaced the mempool with Rusty's "RCU allocating RCU structure with the object-to-be-freed together" solution. Patch is for 2.5.44-mm6, compiled and tested.

Please review and apply if you like.

Mingming
--------------------------------------------------------------------------------

msg.c  |    2 -
sem.c  |    6 +--
shm.c  |    2 -
util.c |  104
++++++++++++++++++++++++++++++++++-------------------------------
util.h |   23 ++++++++++----
5 files changed, 77 insertions(+), 60 deletions(-)
ipc/msg.c +1 -1
diff -urN 2544-mm6/ipc/msg.c 2544-mm6-ipc/ipc/msg.c
@@ -93,7 +93,7 @@
 	int retval;
 	struct msg_queue *msq;
 
-	msq  = (struct msg_queue *) kmalloc (sizeof (*msq), GFP_KERNEL);
+	msq  = (struct msg_queue *) ipc_rcu_alloc (sizeof (*msq));
 	if (!msq) 
 		return -ENOMEM;
 
ipc/sem.c +3 -3
diff -urN 2544-mm6/ipc/sem.c 2544-mm6-ipc/ipc/sem.c
@@ -126,7 +126,7 @@
 		return -ENOSPC;
 
 	size = sizeof (*sma) + nsems * sizeof (struct sem);
-	sma = (struct sem_array *) ipc_alloc(size);
+	sma = (struct sem_array *) ipc_rcu_alloc(size);
 	if (!sma) {
 		return -ENOMEM;
 	}
@@ -138,14 +138,14 @@
 	sma->sem_perm.security = NULL;
 	retval = security_ops->sem_alloc_security(sma);
 	if (retval) {
-		ipc_free(sma, size);
+		ipc_rcu_free(sma, size);
 		return retval;
 	}
 
 	id = ipc_addid(&sem_ids, &sma->sem_perm, sc_semmni);
 	if(id == -1) {
 		security_ops->sem_free_security(sma);
-		ipc_free(sma, size);
+		ipc_rcu_free(sma, size);
 		return -ENOSPC;
 	}
 	used_sems += nsems;
ipc/shm.c +1 -1
diff -urN 2544-mm6/ipc/shm.c 2544-mm6-ipc/ipc/shm.c
@@ -180,7 +180,7 @@
 	if (shm_tot + numpages >= shm_ctlall)
 		return -ENOSPC;
 
-	shp = (struct shmid_kernel *) kmalloc (sizeof (*shp), GFP_USER);
+	shp = (struct shmid_kernel *) ipc_rcu_alloc (sizeof (*shp));
 	if (!shp)
 		return -ENOMEM;
 
ipc/util.c +55 -49

169 lines not on this page · raw message

ipc/util.h +17 -6
diff -urN 2544-mm6/ipc/util.h 2544-mm6-ipc/ipc/util.h
@@ -9,17 +9,24 @@
 
 #define USHRT_MAX 0xffff
 #define SEQ_MULTIPLIER	(IPCMNI)
-#define MAX_RCU_BACKUPS	4	/*max # of elements in rcu_backup_pool*/
 
 void sem_init (void);
 void msg_init (void);
 void shm_init (void);
 
-struct rcu_ipc_free {
-	struct rcu_head		rcu_head;
-	void 			*ptr;
-	int 			size;
-	struct work_struct	work;
+struct ipc_rcu_kmalloc
+{
+	struct rcu_head rcu;
+	/* "void *" makes sure alignment of following data is sane. */
+	void *data[0];
+};
+
+struct ipc_rcu_vmalloc
+{
+	struct rcu_head rcu;
+	struct work_struct work;
+	/* "void *" makes sure alignment of following data is sane. */
+	void *data[0];
 };
 
 struct ipc_ids {
@@ -52,6 +59,10 @@
  */
 void* ipc_alloc(int size);
 void ipc_free(void* ptr, int size);
+/* for allocation that need to be freed by RCU
+ * both function can sleep
+ */
+void* ipc_rcu_alloc(int size);
 void ipc_rcu_free(void* arg, int size);
 
 struct kern_ipc_perm* ipc_get(struct ipc_ids* ids, int id);
#5 lore raw
In reply to Rusty Russell
Quoted 9 lines · Rusty Russell
Quoted 2 lines

No bound to the number of possible OOM kills, but what problem is that?

Sorry, I'm obviously not making myself clear, since I've said this three times now.

1) The memory is required for one whole RCU period (whether from kmalloc or the mempool). This can be an almost arbitrarily long time (I've seen it take a good fraction of a second).

That's a very short time compared with an OOMing thrash: no worries there.

Quoted 2 lines

2) This is a problem, because other tasks could be OOM killed during that period, and could also try to use this mempool.

They'll try to use the mempool, maybe some will be allowed to wait for their kmalloc(GFP_KERNEL) memory, and others will be PF_MEMDIEd and proceed to take a reserved mempool buffer, and others will be PF_MEMDIEd and have to wait for a reserved mempool buffer. Which will be released to them in due course. No worries there.

Quoted 3 lines

3) So, the size of the mempool which guarantees there will be enough? It's equal to the number of things you might free, which means you might as well allocate them together.

No, they take their turns. It's sure not as efficient as each getting a kmalloc'ed buffer immediately, but its failures will be rare. And it doesn't matter whether the failures only occur when heading for OOM-kill or not: we just don't want failure to be the common case. If kmalloc evolves into something that normally fails half the time, well, I'd think that'd be called a bug.

Quoted 1 line

This is the correctness problem with the mempool IPC implementation.

No. There may be other situations which might need at least NR_CPUS reserved mempool buffer to avoid deadlock, but that's not the case here. Looks like mempool will be superseded as you wish in the IPC context, fine; but I do think you need to take a look at mempool_alloc: it's a different beast from what you suppose.

Hugh

#6 lore raw

In message <[email protected]> you write:

Quoted 8 lines
Quoted 2 lines

2) This is a problem, because other tasks could be OOM killed during that period, and could also try to use this mempool.

They'll try to use the mempool, maybe some will be allowed to wait for their kmalloc(GFP_KERNEL) memory, and others will be PF_MEMDIEd and proceed to take a reserved mempool buffer, and others will be PF_MEMDIEd and have to wait for a reserved mempool buffer. Which will be released to them in due course. No worries there.

Oh.

You are (of course) correct. Thankyou for your patience. Your solution is elegant and correct.

Feeling dimwitted,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#7 lore raw
In reply to Rusty Russell

Hi Rusty,

I am pathologically late in catching up lkml, so if I missed some context here, I apologize in advance. I have just started looking at mm6 ipc code and I want to point out a few things.

Quoted 4 lines · Rusty Russell

Yes, nonsensical. Firstly, it's in violation of the standard to fail IPC_RMID under random circumstances. Secondly, failing to clean up is an unhandlable error, since you're quite possible in the failure path of the code already. This is a well known issue.

I am not sure how Ming/Hugh's current IPC changes affect IPC_RMID. It affects only when you are trying to add a new ipc. In fact, since it is a *add* operation (grow_ary()), it seems ok to fail it if rcu_head allocation fails. Feel free to correct me if I missed something here. AFAICS, the rcu stuff doesn't affect any freeing other than the IPC id array.

Quoted 6 lines

Two oom kills. Three oom kills. Four oom kills. Where's the bound here?

Our allocator behavior for GFP_KERNEL has changed several times. Are you sure that it won't *ever* fail under other circomstances?

Quoted 6 lines
Quoted 3 lines

Okay (I expect, didn't review it) for just the ids arrays, but too much memory waste if we have to allocate for each msq, sema, shm: if there's a better solution available. mempool looks better to us.

It's a hacky, fragile and incorrect solution. It's completely tasteless.

Yes, the mempool code is broken, but only because rcu_backup_pool is created three times, one by each IPC mechanism init :-)

Quoted 7 lines
Quoted 3 lines

Not yet. You seem to have had a bad experience with something like this (the mempools or the RCU or the combination), and you're warning us away without actually telling us what you found.

I *wrote* the RCU interface (though the implementation in 2.5 isn't mine). I thought it was pretty clear how it was supposed to be used. Obviously, I was wrong.

Yes, we went through this a long time ago and the general model is to embedd the rcu_head thereby allocating it at the time of allocation of the RCU protected data. This increases the probability of recovery from low-memory situation as compared to having to allocte during freeing.

That said, it seems that Ming/Hugh's patch does allocate the rcu_head at the time of *growing* the array. It is just that they allocate it for the freeing array rather than the allocated array. I don't see how this is semantically different from clubbing the two allocations other than the fact that smaller number of allocation calls would likely reduce the likelyhood of allocation failures.

Quoted 2 lines

Patch below is against Mingming's mm4 release. Compiles, untested. Rusty.

Yes, this is the typical RCU model, except that in this case (IPC), I am not quite sure if it is in effect that different from what Ming/Hugh have done.

Thanks
Dipankar

#8 lore raw
Quoted 7 lines · Dipankar Sarma
Quoted 4 lines · Rusty Russell

Yes, nonsensical. Firstly, it's in violation of the standard to fail IPC_RMID under random circumstances. Secondly, failing to clean up is an unhandlable error, since you're quite possible in the failure path of the code already. This is a well known issue.

Quoted 7 lines

I am not sure how Ming/Hugh's current IPC changes affect IPC_RMID. It affects only when you are trying to add a new ipc. In fact, since it is a *add* operation (grow_ary()), it seems ok to fail it if rcu_head allocation fails. Feel free to correct me if I missed something here. AFAICS, the rcu stuff doesn't affect any freeing other than the IPC id array.

We extended the usage of RCU to IPC_RMID, to prevent ipc_lock() returning an invalid IPC ID which has been removed by ioc_rmid.

Quoted 6 lines
Quoted 2 lines

It's a hacky, fragile and incorrect solution. It's completely tasteless.

Yes, the mempool code is broken, but only because rcu_backup_pool is created three times, one by each IPC mechanism init :-)

That's my bad, thanks for pointing this out. It's easy to fix if we decide to go with mempool way.

Quoted 6 lines
Quoted 2 lines

Patch below is against Mingming's mm4 release. Compiles, untested. Rusty.

Yes, this is the typical RCU model, except that in this case (IPC), I am not quite sure if it is in effect that different from what Ming/Hugh have done.

Rusty's patch looks good to me. I would like to replace the mempool in IPC with this typical RCU model. Rusty, if you like, I will make a patch against mm6. There need some cleanups. One thing is that ipc_alloc() are called by other places(besides grow_ary()), and they don't need to the RCU header structure.

Mingming

#9 lore raw

In message <[email protected]> you write:

Quoted 9 lines
Quoted 3 lines

Yes, this is the typical RCU model, except that in this case (IPC), I am not quite sure if it is in effect that different from what Ming/Hugh have done.

Rusty's patch looks good to me. I would like to replace the mempool in IPC with this typical RCU model. Rusty, if you like, I will make a patch against mm6. There need some cleanups. One thing is that ipc_alloc() are called by other places(besides grow_ary()), and they don't need to the RCU header structure.

Yes, I noticed that, but I'm not sure it's worth separating ipc_alloc() and ipc_rcu_alloc() for a couple of temporary allocations.

Anyway, glad you like the patch,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#10 lore raw
In reply to Dipankar Sarma

In message <20021029013059.A13287@dikhow> you write:

Quoted 5 lines

Hi Rusty,

I am pathologically late in catching up lkml, so if I missed some context here, I apologize in advance. I have just started looking at mm6 ipc code and I want to point out a few things.

That's OK, I'm still 1500 behind 8(

If all current uses are embedded, can we remove the "void
*arg" and reduce the size of struct rcu_head by 25%? Users can always embed it in their own struct which has a "void *arg", but if that's the uncommon case, it'd be nice to slim it a little.

It'd also be nice to change the double linked list to a single
too: as far as I can tell the only issue is the list_add_tail in call_rcu(): how important is this ordering? It can be done by keeping a head as well as a tail pointer if required.

I'd be happy to prepare a patch, to avoid more complaints of bloat 8)

Quoted 7 lines

That said, it seems that Ming/Hugh's patch does allocate the rcu_head at the time of *growing* the array. It is just that they allocate it for the freeing array rather than the allocated array. I don't see how this is semantically different from clubbing the two allocations other than the fact that smaller number of allocation calls would likely reduce the likelyhood of allocation failures.

We must be looking at different variants of the patch. This one does:
IPC_RMID -> freeary() -> ipc_rcu_free -> kmalloc.

Cheers,
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

#11 lore raw
Quoted 4 lines · Rusty Russell

If all current uses are embedded, can we remove the "void
*arg" and reduce the size of struct rcu_head by 25%? Users can always embed it in their own struct which has a "void *arg", but if that's the uncommon case, it'd be nice to slim it a little.

All current cases are not embedded, synchronize_kernel() needs "arg" :-)

Quoted 5 lines

It'd also be nice to change the double linked list to a single
too: as far as I can tell the only issue is the list_add_tail in call_rcu(): how important is this ordering? It can be done by keeping a head as well as a tail pointer if required.

I can't see how the ordering of the RCU updates matter, so we can trivially change things internally without affecting the interface.

That said, I disagree about the bloat issue, I don't see a problem there, atleast not yet. All the uses that I have seen so far, the additional "prev" pointer is a very small fraction of the total memory allocated for the objects. And it is certainly not an issue with IPC - just look at the values for SHMMNI, SEMMNI etc.

Quoted 3 lines

We must be looking at different variants of the patch. This one does:
IPC_RMID -> freeary() -> ipc_rcu_free -> kmalloc.

Grr... I thought Mingming's patch modified only IPC common code and was looking at the mm6 tree directly. My earlier suggestion is valid only if RCU head allocation is limited to grow_ary(). Otherwise, rcu_head should be embedded.

Thanks

Signature · 2 lines
Dipankar Sarma  <[email protected]> http://lse.sourceforge.net
Linux Technology Center, IBM Software Lab, Bangalore, India.