Hi, Maarten!I'll fold it in to the patch that added reservation_object_reserve_shared.
Some nitpicks, and that krealloc within rcu lock still worries me.
Otherwise looks good.
/Thomas
On 04/23/2014 12:15 PM, Maarten Lankhorst wrote:
@@ -55,8 +60,8 @@ int reservation_object_reserve_shared(structPerhaps as a separate reformatting patch?
reservation_object *obj)
kfree(obj->staged);
obj->staged = NULL;
return 0;
- }
- max = old->shared_max * 2;
+ } else
+ max = old->shared_max * 2;
Yes it is, shared_count may be increased, leading to potential different sizes for krealloc and memcpy+ACCESS_ONCE() shouldn't be needed inside the seqlock?
+int reservation_object_get_fences_rcu(struct reservation_object *obj,
+ struct fence **pfence_excl,
+ unsigned *pshared_count,
+ struct fence ***pshared)
+{
+ unsigned shared_count = 0;
+ unsigned retry = 1;
+ struct fence **shared = NULL, *fence_excl = NULL;
+ int ret = 0;
+
+ while (retry) {
+ struct reservation_object_list *fobj;
+ unsigned seq;
+
+ seq = read_seqcount_begin(&obj->seq);
+
+ rcu_read_lock();
+
+ fobj = rcu_dereference(obj->fence);
+ if (fobj) {
+ struct fence **nshared;
+
+ shared_count = ACCESS_ONCE(fobj->shared_count);
But shared_count is only known when holding the rcu lock.+ nshared = krealloc(shared, sizeof(*shared) *Again, krealloc should be a sleeping function, and not suitable within a
shared_count, GFP_KERNEL);
RCU read lock? I still think this krealloc should be moved to the start
of the retry loop, and we should start with a suitable guess of
shared_count (perhaps 0?) It's not like we're going to waste a lot of
memory....
Oops.+Typo.
+ /*
+ * There could be a read_seqcount_retry here, but nothing cares
+ * about whether it's the old or newer fence pointers that are
+ * signale. That race could still have happened after checking