This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
something wrong with the counter of MBuf
Hi, all,
I tried to know how many mbufs left at any time so I used
[void cyg_kmem_print_stats(void)] in support.c periodically.
I knew that everytime we allocate a mbuf, we will have
"mbstat.m_mbufs++", and when we free a mbuf, we will
have "mbstat.m_mbuf--". But after I looked into the source
code, I found maybe there was something wrong with the
counter of mbuf.
In OpenBSD(net), we have "mbstat.m_mbufs++" in
[void *cyg_net_mbuf_alloc(int type, int flags)]
in support.c. We can't get any one if there is none but
the counter will still get increment. I suppose we should
check if we indeed get a mbuf and then add 1 to
"mbstat.mbufs" in the ending instead of adding in the
beginning of this function. You think?
In FreeBSD(new_net), we have "mbstat.m_mbufs++" in
both [void *cyg_net_mbuf_alloc(int type, int flags)]
in support.c and [int m_mballoc(register int nmb, int how)]
in uipc_mbuf.c. Then we get the increment twice! Since
in [int m_mballoc(register int nmb, int how)] in uipc_mbuf.c
we will check if we indeed get a mbuf and increase the
counter, I suppose the "mbstat.m_mbufs++" in support.c
is redundant. What is your opnion?
Regards,
Jimmy
--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss