From: Pranjal Shrivastava <praan@google.com>
To: Nicolin Chen <nicolinc@nvidia.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>, Joerg Roedel <joro@8bytes.org>,
Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Mostafa Saleh <smostafa@google.com>,
iommu@lists.linux.dev, Daniel Mentz <danielmentz@google.com>
Subject: Re: [PATCH v3 1/2] iommu/arm-smmu-v3: Print better events records
Date: Thu, 3 Oct 2024 21:26:36 +0000 [thread overview]
Message-ID: <Zv8MDB4a_P3Jj6x1@google.com> (raw)
In-Reply-To: <Zv2BRcOjpLSe+1cn@Asurada-Nvidia>
On Wed, Oct 02, 2024 at 10:22:13AM -0700, Nicolin Chen wrote:
> On Wed, Oct 02, 2024 at 02:10:52PM -0300, Jason Gunthorpe wrote:
> > On Wed, Oct 02, 2024 at 09:55:14AM -0700, Nicolin Chen wrote:
> > > > dev_name()'s result can't leave the lock either, at least not with out
> > > > some refcounting on the struct device.
Agreed, I missed that! Maybe we can avoid reading the master name in the
`arm_smmu_get_evt_info` and move it within the `arm_smmu_handle_evt`
under proper locking? Since the event won't be dumped before it's
handled, we can avoid locking at two places for doing the same thing?
> > >
> > > I found dev_name returns "const char *" so the string source is
> > > likely in the data section? If so, could the result of a locked
> > > "master_name = dev_name()" get away from the lock?
> >
> > The name is allocated memory freed when the struct device is freed.
>
> Oh, reading it a bit further, I found kfree_const() at kobj->name
> and some of the dev->init_names aren't coming from static strings.
>
> We could kstrdup alternatively, but keeping the dump() inside the
> lock is just simpler.
kstrdup is a good idea too.. overall, I wouldn't wanna *accidentally*
mess up locking for logging (no rhymes intended).
Hence, we have 2 options:
1. Read the master_name within `arm_smmu_handle_evt` (at one place only)
2. Use kstrdup to copy the master_name elsewhere and dereference it.
Personally, I won't prefer 2 as we'd also have to free the memory
allocated for the dup'ed string after logging everything in
`arm_smmu_handle_evt` which is a bottom-half. LMK what y'all think?
>
> Thanks!
> Nicolin
Thanks,
Pranjal
next prev parent reply other threads:[~2024-10-03 21:26 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-28 0:51 [PATCH v3 0/2] Parse out event records Pranjal Shrivastava
2024-09-28 0:51 ` [PATCH v3 1/2] iommu/arm-smmu-v3: Print better events records Pranjal Shrivastava
2024-09-30 19:15 ` Nicolin Chen
2024-10-01 20:52 ` Pranjal Shrivastava
2024-10-01 23:04 ` Nicolin Chen
2024-10-02 13:57 ` Jason Gunthorpe
2024-10-02 16:55 ` Nicolin Chen
2024-10-02 17:10 ` Jason Gunthorpe
2024-10-02 17:22 ` Nicolin Chen
2024-10-03 21:26 ` Pranjal Shrivastava [this message]
2024-10-03 22:50 ` Nicolin Chen
2024-10-11 7:53 ` Pranjal Shrivastava
2024-10-11 10:02 ` Pranjal Shrivastava
2024-09-28 0:51 ` [PATCH v3 2/2] iommu/arm-smmu-v3: Adopt arm_smmu_event in handlers Pranjal Shrivastava
2024-09-30 19:32 ` Nicolin Chen
2024-10-01 21:02 ` Pranjal Shrivastava
2024-10-01 22:59 ` Nicolin Chen
2024-10-03 21:34 ` Pranjal Shrivastava
2024-10-03 22:53 ` Nicolin Chen
2024-10-11 7:55 ` Pranjal Shrivastava
2024-10-11 10:21 ` Robin Murphy
2024-10-11 10:45 ` Pranjal Shrivastava
2024-10-11 11:06 ` Pranjal Shrivastava
2024-10-11 12:59 ` Robin Murphy
2024-10-11 20:31 ` Pranjal Shrivastava
2024-10-15 18:34 ` Pranjal Shrivastava
2024-10-15 20:03 ` Robin Murphy
2024-10-17 8:06 ` Pranjal Shrivastava
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=Zv8MDB4a_P3Jj6x1@google.com \
--to=praan@google.com \
--cc=danielmentz@google.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=smostafa@google.com \
--cc=will@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.