git: msgport: Add putport_oncpu; helps scheduling netisr locally for spin port

Sepherosa Ziehau sephe at crater.dragonflybsd.org
Wed Oct 30 07:19:50 PDT 2013


commit c068fb592b4c6a5bb7a2d94a0c7869ee2a18b773
Author: Sepherosa Ziehau <sephe at dragonflybsd.org>
Date:   Wed Oct 30 21:50:55 2013 +0800

    msgport: Add putport_oncpu; helps scheduling netisr locally for spin port
    
    Background:
    High rate (actually same rate as polling(4)) IPIs on random CPUs are
    observed when polling(4) is enabled and there is virtually no network
    activity.
    
    After polling(4) activities are traced using ktr(9), it turns out that the
    high rate IPIs are actually from the wakeup() on netisr's msgport.  Since
    the sleep queue cpumask is indexed by the hash of ident, there are chances
    that the netisr's msgport ident has the same hash value as other idents
    that certain threads on other CPUs are waiting on.  If this ever happens
    (well, it does happen), the netisr's msgport wakeup will trigger "wakeup"
    IPIs to other CPUs.  However, these "wakeup" IPIs are actually useless,
    since only netisr will wait on its msgport.
    
    putport_oncpu() msgport method is added to call wakeup_mycpu() for spin
    msgport, if we know that this port is only accessed by one thread on the
    current CPU, e.g. polling(4).  This is also the case for other network
    code, e.g.  syncache timeout, TCP timeout, fastforward flow cache timeout
    etc.  However, these network code's running rate is too low to unveil the
    extra "wakeup" IPIs problem.  lwkt_sendmsg_oncpu() is added as wrapper to
    putport_oncpu() msgport method.
    
    Currently, only polling(4) is using lwkt_sendmsg_oncpu().  Others will
    be converted soon.

Summary of changes:
 sys/kern/lwkt_msgport.c | 112 +++++++++++++++++++++++++++++++++++++++++-------
 sys/kern/lwkt_thread.c  |   8 ++--
 sys/net/if.c            |   2 +-
 sys/net/if_poll.c       |   2 +-
 sys/net/netisr.c        |   3 +-
 sys/sys/msgport.h       |   5 ++-
 sys/sys/msgport2.h      |   7 ---
 sys/sys/thread.h        |   2 +-
 8 files changed, 111 insertions(+), 30 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/c068fb592b4c6a5bb7a2d94a0c7869ee2a18b773


-- 
DragonFly BSD source repository



More information about the Commits mailing list