This is the mail archive of the ecos-discuss@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FreeBSD IP stack deadlock - patch


hi,

here is a proposed patch to fix a possible deadlock situation
in the ecos port of the FreeBSD IP stack.

In sosend() (uipc_socket.c:553) there is blocking wait for
a mbuf ( MGET(WAIT) ). Let us assume the stack is running out of MBufs
(e.g. under heavy IP traffic).

Since the mbuf "free-list" is empty and the mbuf pool is also empty
a MGET(WAIT) performs at last a cyg_mempool_fix_alloc() call, wich
is blocking forever. Also the mutex splimp() is locked forever.

Note: MBufs are freed back to the "free-list" but are never
freed back to pool.

Further the mbuf statistic counter increments twice.
mbstat.m_mbufs++ is done in cyg_net_mbuf_alloc() and also
in m_mballoc() (both in file uipc_mbuf.c).

The patch prevents a blocking alloc of MBufs. It is
done similar to the cluster alloc mechanism.
Double mbuf counting was fixed also.

regards, Christoph


ChangeLog entry:

2004-03-30  Horst Kronstorfer  <horst.kronstorfer@frequentis.com>

        * src/sys/kern/uipc_mbuf.c
        * src/ecos/support.c
        * include/sys/mbuf.h: Avoid blocking alloc from (empty) mbuf pool,
        because freed mbufs are never returned to the pool, but to the mbuf
        "free list" (deadlock situation).
        Duplicated counting of mbuf statistics removed.

-- 

Attachment: patch1
Description: Text document

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]