From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Konstantin Ananyev" <konstantin.ananyev@huawei.com>,
<andrew.rybchenko@oktetlabs.ru>, <konstantin.v.ananyev@yandex.ru>,
<paul.szczepanek@arm.com>, <stephen@networkplumber.org>
Cc: <dev@dpdk.org>
Subject: RE: [PATCH] mempool: dump includes list of memory chunks
Date: Mon, 10 Jun 2024 16:51:04 +0200 [thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35E9F511@smartserver.smartshare.dk> (raw)
In-Reply-To: <4436395406f544d5ba225dd7ffa7f07b@huawei.com>
> From: Konstantin Ananyev [mailto:konstantin.ananyev@huawei.com]
> Sent: Monday, 10 June 2024 15.45
>
> > Added information about the memory chunks holding the objects in the
> > mempool when dumping the status of the mempool to a file.
> >
> > Signed-off-by: Morten Brørup <mb@smartsharesystems.com>
> > ---
> > lib/mempool/rte_mempool.c | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> > diff --git a/lib/mempool/rte_mempool.c b/lib/mempool/rte_mempool.c
> > index 12390a2c81..e9a8a5b411 100644
> > --- a/lib/mempool/rte_mempool.c
> > +++ b/lib/mempool/rte_mempool.c
> > @@ -1230,6 +1230,7 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
> > #endif
> > struct rte_mempool_memhdr *memhdr;
> > struct rte_mempool_ops *ops;
> > + unsigned int n;
> > unsigned common_count;
> > unsigned cache_count;
> > size_t mem_len = 0;
> > @@ -1264,6 +1265,15 @@ rte_mempool_dump(FILE *f, struct rte_mempool *mp)
> > (long double)mem_len / mp->size);
> > }
> >
> > + fprintf(f, " mem_list:\n");
> > + n = 0;
> > + STAILQ_FOREACH(memhdr, &mp->mem_list, next) {
> > + fprintf(f, " addr[%u]=%p\n", n, memhdr->addr);
> > + fprintf(f, " iova[%u]=0x%" PRIx64 "\n", n, memhdr->iova);
> > + fprintf(f, " len[%u]=%zu\n", n, memhdr->len);
> > + n++;
> > + }
> > +
> > cache_count = rte_mempool_dump_cache(f, mp);
> > common_count = rte_mempool_ops_get_count(mp);
> > if ((cache_count + common_count) > mp->size)
> > --
>
> Just as a thought: do we want to print something (N/A?) when mp->mem_list is
> empty?
Good idea, Konstantin.
Your feedback made me check what other dump functions print when the list is empty, and I saw that the mbuf library's dump function prints segments with multiple fields on the same line [1], as previously suggested by Stephen (and rejected by me, because I thought it was breaking conventions).
[1]: https://elixir.bootlin.com/dpdk/v24.03/source/lib/mbuf/rte_mbuf.c#L694
Admitting that Stephen was on the right track with his suggestion, and I was wrong to reject it, we could omit the "mem_list:" header and print the list like this instead:
STAILQ_FOREACH(memhdr, &mp->mem_list, next)
fprintf(f, " memory chunk at %p, addr=%p, iova=0x%" PRIx64 ", len=%zu\n",
memhdr, memhdr->addr, memhdr->iova, memhdr->len);
The patch will be just these three lines of code, and nothing will be printed if the list is empty.
What do you think?
>
> Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
>
>
> > 2.17.1
next prev parent reply other threads:[~2024-06-10 14:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-16 8:59 Morten Brørup
2024-05-16 15:20 ` Stephen Hemminger
2024-05-17 7:29 ` Morten Brørup
2024-05-29 12:55 ` Paul Szczepanek
2024-05-29 14:03 ` Morten Brørup
2024-06-10 9:13 ` Morten Brørup
2024-06-10 11:56 ` Andrew Rybchenko
2024-06-10 13:44 ` Konstantin Ananyev
2024-06-10 14:51 ` Morten Brørup [this message]
2024-06-10 16:28 ` Konstantin Ananyev
2024-06-11 6:38 ` [PATCH v2] " Morten Brørup
2024-06-11 6:50 ` Morten Brørup
2024-06-11 6:51 ` [PATCH v3] " Morten Brørup
2024-06-11 11:27 ` lihuisong (C)
2024-06-14 14:10 ` David Marchand
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=98CBD80474FA8B44BF855DF32C47DC35E9F511@smartserver.smartshare.dk \
--to=mb@smartsharesystems.com \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=konstantin.ananyev@huawei.com \
--cc=konstantin.v.ananyev@yandex.ru \
--cc=paul.szczepanek@arm.com \
--cc=stephen@networkplumber.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;
as well as URLs for NNTP newsgroup(s).