Home » Mailing lists » Devel » [PATCH] BC: resource beancounters (v2)
Re: [PATCH 2/6] BC: beancounters core (API) [message #5612 is a reply to message #5568] |
Thu, 24 August 2006 12:03   |
dev
Messages: 1693 Registered: September 2005 Location: Moscow
|
Senior Member |

|
|
Andrew Morton wrote:
[... snip ...]
>>+#define bc_charge_locked(bc, r, v, s) (0)
>>> +#define bc_charge(bc, r, v) (0)
>
>akpm:/home/akpm> cat t.c
>void foo(void)
>{
> (0);
>}
>akpm:/home/akpm> gcc -c -Wall t.c
>t.c: In function 'foo':
>t.c:4: warning: statement with no effect
these functions return value should always be checked (!).
i.e. it is never called like:
ub_charge(bc, r, v);
>>+struct beancounter *beancounter_findcreate(uid_t uid, int mask)
>>+{
>>+ struct beancounter *new_bc, *bc;
>>+ unsigned long flags;
>>+ struct hlist_head *slot;
>>+ struct hlist_node *pos;
>>+
>>+ slot = &bc_hash[bc_hash_fun(uid)];
>>+ new_bc = NULL;
>>+
>>+retry:
>>+ spin_lock_irqsave(&bc_hash_lock, flags);
>>+ hlist_for_each_entry (bc, pos, slot, hash)
>>+ if (bc->bc_id == uid)
>>+ break;
>>+
>>+ if (pos != NULL) {
>>+ get_beancounter(bc);
>>+ spin_unlock_irqrestore(&bc_hash_lock, flags);
>>+
>>+ if (new_bc != NULL)
>>+ kmem_cache_free(bc_cachep, new_bc);
>>+ return bc;
>>+ }
>>+
>>+ if (!(mask & BC_ALLOC))
>>+ goto out_unlock;
>>+
>>+ if (new_bc != NULL)
>>+ goto out_install;
>>+
>>+ spin_unlock_irqrestore(&bc_hash_lock, flags);
>>+
>>+ new_bc = kmem_cache_alloc(bc_cachep,
>>+ mask & BC_ALLOC_ATOMIC ? GFP_ATOMIC : GFP_KERNEL);
>>+ if (new_bc == NULL)
>>+ goto out;
>>+
>>+ memcpy(new_bc, &default_beancounter, sizeof(*new_bc));
>>+ init_beancounter_struct(new_bc, uid);
>>+ goto retry;
>>+
>>+out_install:
>>+ hlist_add_head(&new_bc->hash, slot);
>>+out_unlock:
>>+ spin_unlock_irqrestore(&bc_hash_lock, flags);
>>+out:
>>+ return new_bc;
>>+}
>
>
> Can remove the global bc_hash_lock and make the locking per-hash-bucket.
it is not performance critical path IMHO.
this lock is taken on container create/change/destroy/user interfaces only.
>>+static inline void verify_held(struct beancounter *bc)
>>+{
>>+ int i;
>>+
>>+ for (i = 0; i < BC_RESOURCES; i++)
>>+ if (bc->bc_parms[i].held != 0)
>>+ bc_print_resource_warning(bc, i,
>>+ "resource is held on put", 0, 0);
>>+}
>>+
>>+void __put_beancounter(struct beancounter *bc)
>>+{
>>+ unsigned long flags;
>>+
>>+ /* equivalent to atomic_dec_and_lock_irqsave() */
>>+ local_irq_save(flags);
>>+ if (likely(!atomic_dec_and_lock(&bc->bc_refcount, &bc_hash_lock))) {
>>+ local_irq_restore(flags);
>>+ if (unlikely(atomic_read(&bc->bc_refcount) < 0))
>>+ printk(KERN_ERR "BC: Bad refcount: bc=%p, "
>>+ "luid=%d, ref=%d\n",
>>+ bc, bc->bc_id,
>>+ atomic_read(&bc->bc_refcount));
>>+ return;
>>+ }
>>+
>>+ BUG_ON(bc == &init_bc);
>>+ verify_held(bc);
>>+ hlist_del(&bc->hash);
>>+ spin_unlock_irqrestore(&bc_hash_lock, flags);
>>+ kmem_cache_free(bc_cachep, bc);
>>+}
>
> I wonder if it's safe and worthwhile to optimise away the local_irq_save():
>
> if (atomic_dec_and_test(&bc->bc_refcount)) {
> spin_lock_irqsave(&bc_hash_lock, flags);
> if (atomic_read(&bc->bc_refcount) == 0) {
> free it
put_beancounter can happen from IRQ context.
so we need something like atomic_dec_and_lock_irqsave()
Oleg Nesterov proposed more details.
Thanks,
Kirill
|
|
|
 |
|
[PATCH] BC: resource beancounters (v2)
By: dev on Wed, 23 August 2006 10:44
|
 |
|
[PATCH 1/6] BC: kconfig
By: dev on Wed, 23 August 2006 10:59
|
 |
|
Re: [PATCH 1/6] BC: kconfig
|
 |
|
Re: [PATCH 1/6] BC: kconfig
|
 |
|
Re: [PATCH 1/6] BC: kconfig
|
 |
|
Re: [PATCH 1/6] BC: kconfig
By: dev on Fri, 25 August 2006 11:27
|
 |
|
Re: [PATCH 1/6] BC: kconfig
By: dev on Fri, 25 August 2006 11:31
|
 |
|
Re: [PATCH 1/6] BC: kconfig
By: rdunlap on Wed, 23 August 2006 22:29
|
 |
|
Re: [PATCH 1/6] BC: kconfig
|
 |
|
Re: [PATCH 1/6] BC: kconfig
|
 |
|
Re: [ckrm-tech] [PATCH 1/6] BC: kconfig
By: dev on Thu, 24 August 2006 11:47
|
 |
|
Re: [ckrm-tech] [PATCH 1/6] BC: kconfig
|
 |
|
[PATCH 2/6] BC: beancounters core (API)
By: dev on Wed, 23 August 2006 11:00
|
 |
|
Re: [PATCH 2/6] BC: beancounters core (API)
|
 |
|
Re: [PATCH 2/6] BC: beancounters core (API)
By: dev on Wed, 23 August 2006 13:25
|
 |
|
Re: [PATCH 2/6] BC: beancounters core (API)
|
 |
|
Re: [PATCH 2/6] BC: beancounters core (API)
By: dev on Wed, 23 August 2006 13:46
|
 |
|
Re: [PATCH 2/6] BC: beancounters core (API)
|
 |
|
Re: [PATCH 2/6] BC: beancounters core (API)
|
 |
|
Re: [PATCH 2/6] BC: beancounters core (API)
|
 |
|
Re: [PATCH 2/6] BC: beancounters core (API)
|
 |
|
Re: [PATCH 2/6] BC: beancounters core (API)
|
 |
|
Re: [PATCH 2/6] BC: beancounters core (API)
By: dev on Thu, 24 August 2006 12:03
|
 |
|
Re: [PATCH 2/6] BC: beancounters core (API)
|
 |
|
Re: [PATCH 2/6] BC: beancounters core (API)
By: dev on Fri, 25 August 2006 10:51
|
 |
|
Re: [PATCH 2/6] BC: beancounters core (API)
|
 |
|
[PATCH 3/6] BC: context inheriting and changing
By: dev on Wed, 23 August 2006 11:02
|
 |
|
[PATCH 4/6] BC: user interface (syscalls)
By: dev on Wed, 23 August 2006 11:03
|
 |
|
Re: [PATCH 4/6] BC: user interface (syscalls)
By: dev on Wed, 23 August 2006 13:40
|
 |
|
Re: [PATCH 4/6] BC: user interface (syscalls)
|
 |
|
Re: [PATCH 4/6] BC: user interface (syscalls)
By: Alan Cox on Wed, 23 August 2006 17:08
|
 |
|
Re: [PATCH 4/6] BC: user interface (syscalls)
|
 |
|
Re: [PATCH 4/6] BC: user interface (syscalls)
By: Alan Cox on Thu, 24 August 2006 10:42
|
 |
|
Re: [PATCH 4/6] BC: user interface (syscalls)
|
 |
|
Re: [PATCH 4/6] BC: user interface (syscalls)
By: dev on Fri, 25 August 2006 10:54
|
 |
|
Re: [PATCH 4/6] BC: user interface (syscalls)
|
 |
|
Re: [PATCH 4/6] BC: user interface (syscalls)
|
 |
|
[PATCH 5/6] BC: kernel memory accounting (core)
By: dev on Wed, 23 August 2006 11:04
|
 |
|
Re: [PATCH 5/6] BC: kernel memory accounting (core)
|
 |
|
Re: [PATCH 5/6] BC: kernel memory accounting (core)
|
 |
|
Re: [PATCH 5/6] BC: kernel memory accounting (core)
By: dev on Fri, 25 August 2006 10:06
|
 |
|
[PATCH 6/6] BC: kernel memory accounting (marks)
By: dev on Wed, 23 August 2006 11:05
|
 |
|
Re: [PATCH 6/6] BC: kernel memory accounting (marks)
|
 |
|
Re: [PATCH 6/6] BC: kernel memory accounting (marks)
By: dev on Tue, 29 August 2006 09:52
|
 |
|
Re: [PATCH 6/6] BC: kernel memory accounting (marks)
|
 |
|
Re: [PATCH 6/6] BC: kernel memory accounting (marks)
|
 |
|
Re: [PATCH 6/6] BC: kernel memory accounting (marks)
|
 |
|
Re: [PATCH 6/6] BC: kernel memory accounting (marks)
|
 |
|
Re: [PATCH 6/6] BC: kernel memory accounting (marks)
By: dev on Tue, 29 August 2006 14:34
|
 |
|
Re: [PATCH 6/6] BC: kernel memory accounting (marks)
By: dev on Tue, 29 August 2006 15:53
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
By: dev on Fri, 25 August 2006 11:47
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
By: dev on Mon, 28 August 2006 08:27
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
|
 |
|
Re: BC: resource beancounters (v2)
|
 |
|
Re: BC: resource beancounters (v2)
|
 |
|
Re: BC: resource beancounters (v2)
|
 |
|
Re: BC: resource beancounters (v2)
|
 |
|
Re: BC: resource beancounters (v2)
By: Alan Cox on Sat, 26 August 2006 16:16
|
 |
|
Re: BC: resource beancounters (v2)
|
 |
|
Re: Re: BC: resource beancounters (v2)
By: kir on Mon, 28 August 2006 17:40
|
 |
|
Re: Re: BC: resource beancounters (v2)
|
 |
|
Re: Re: BC: resource beancounters (v2)
By: Alan Cox on Tue, 29 August 2006 10:15
|
 |
|
Re: Re: BC: resource beancounters (v2)
|
 |
|
Re: Re: BC: resource beancounters (v2)
By: Alan Cox on Tue, 29 August 2006 18:46
|
 |
|
Re: Re: BC: resource beancounters (v2)
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
By: dev on Tue, 29 August 2006 15:33
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
By: Alan Cox on Thu, 24 August 2006 10:38
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
By: Alan Cox on Fri, 25 August 2006 15:36
|
 |
|
Re: [PATCH] BC: resource beancounters (v2)
|
Goto Forum:
Current Time: Mon Jul 21 02:38:42 GMT 2025
Total time taken to generate the page: 0.07658 seconds
|