mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Balbir Singh <balbir_soni@yahoo.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] mempool_resize and sanity checks
Date: Fri, 15 Mar 2002 16:30:40 -0800 (PST)	[thread overview]
Message-ID: <20020316003040.99460.qmail@web13605.mail.yahoo.com> (raw)

In mempool_resize(), I plan to replace the calls
to spin_unlock_irqrestore() -> pool_free -> spin_lock_
irqsave with the new sequence. The newer code
has fewer calls to spin_lock_irqsave and spin_unlock_
restore(). I think the new code should execute faster.

I have tested this code on a UP, if somebody could
test the patch on an SMP box and let me know if it
works, I would be thankful. I also have a sample test
case that uses mempool_resize().

I have also added the BUG_ON sanity checks in
mempool_create().

New Code

if (new_min_nr < pool->min_nr) {
        pool->min_nr = new_min_nr;
        /*      
         * Free possible excess elements.
         */      
        INIT_LIST_HEAD(&tmp_pool_to_free);
        while (pool->curr_nr > pool->min_nr) {
                tmp = pool->elements.next;
                if (tmp == &pool->elements)
                        BUG();  
                list_del(tmp);
                list_add(tmp, &tmp_pool_to_free);
                pool->curr_nr--;
        }       
        spin_unlock_irqrestore(&pool->lock, flags);

        list_for_each(tmp, &tmp_pool_to_free) {
                element = tmp;
                pool->free(element, pool->pool_data);
        }       
        return; 
}       


Original Code

if (new_min_nr < pool->min_nr) {
        pool->min_nr = new_min_nr;
        /*
         * Free possible excess elements.
         */
        while (pool->curr_nr > pool->min_nr) {
                tmp = pool->elements.next;
                if (tmp == &pool->elements)
                        BUG();
                list_del(tmp);
                element = tmp;
                pool->curr_nr--;
                spin_unlock_irqrestore(&pool->lock,
flags);

                pool->free(element, pool->pool_data);

                spin_lock_irqsave(&pool->lock, flags);
        }
        spin_unlock_irqrestore(&pool->lock, flags);
        return;
}

Diffs are attached.

Balbir

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - live college hoops coverage
http://sports.yahoo.com/

             reply	other threads:[~2002-03-16  0:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-16  0:30 Balbir Singh [this message]
2002-03-16  0:38 Balbir Singh

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=20020316003040.99460.qmail@web13605.mail.yahoo.com \
    --to=balbir_soni@yahoo.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®