lkml.org 
[lkml]   [2010]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH 2/2] Rewrite jump_label.c to use binary search
    On Wed, Sep 22, 2010 at 07:31:14AM -0400, Mathieu Desnoyers wrote:
    > > -static struct jump_label_entry *add_jump_label_entry(jump_label_t key, int nr_entries, struct jump_entry *table)
    > > +void patch_jump_table(unsigned long key, enum jump_label_type type,
    > > + struct jump_entry *start, struct jump_entry *stop)
    > > {
    > > - struct hlist_head *head;
    > > - struct jump_label_entry *e;
    > > - u32 hash;
    > > -
    > > - e = get_jump_label_entry(key);
    > > - if (e)
    > > - return ERR_PTR(-EEXIST);
    > > -
    > > - e = kmalloc(sizeof(struct jump_label_entry), GFP_KERNEL);
    > > - if (!e)
    > > - return ERR_PTR(-ENOMEM);
    > > -
    > > - hash = jhash((void *)&key, sizeof(jump_label_t), 0);
    > > - head = &jump_label_table[hash & (JUMP_LABEL_TABLE_SIZE - 1)];
    > > - e->key = key;
    > > - e->table = table;
    > > - e->nr_entries = nr_entries;
    > > - INIT_HLIST_HEAD(&(e->modules));
    > > - hlist_add_head(&e->hlist, head);
    > > - return e;
    > > + struct jump_entry *entry = search_jump_table(start, stop, key);
    > > + if (!entry)
    > > + return;
    > > + while (entry > start && entry[-1].key == key)
    > > + entry--;
    >
    > OK, I like the way it handles patching of multiple entries with the same
    > key at once. Sorting really makes sense here.
    >
    > > + for (; entry < stop && entry->key == key; entry++)
    > > + if (kernel_text_address(entry->code))
    >
    > This does not work for modules I'm afraid, only for the core kernel. You
    > should test for __module_text_address() somewhere.



    No, look:

    int kernel_text_address(unsigned long addr)
    {
    if (core_kernel_text(addr))
    return 1;
    return is_module_text_address(addr);
    }



    > Dumb question: why do you need this test at all ?


    I wonder about that too.



    \
     
     \ /
      Last update: 2010-09-22 13:59    [W:0.028 / U:0.192 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site