All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 3/3] xfs: use %px for data pointers when debugging
Date: Tue, 9 Jan 2018 15:16:46 -0800	[thread overview]
Message-ID: <20180109231646.GQ5602@magnolia> (raw)
In-Reply-To: <20180109230409.GP16421@dastard>

On Wed, Jan 10, 2018 at 10:04:09AM +1100, Dave Chinner wrote:
> On Tue, Jan 09, 2018 at 12:46:11PM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Starting with commit 57e734423ad ("vsprintf: refactor %pK code out of
> > pointer"), the behavior of the raw '%p' printk format specifier was
> > changed to print a 32-bit hash of the pointer value to avoid leaking
> > kernel pointers into dmesg.  For most situations that's good.
> > 
> > This is /undesirable/ behavior when we're trying to debug XFS, however,
> > so define a PTR_FMT that prints the actual pointer when we're in debug
> > mode.
> > 
> > Note that %p for tracepoints still prints the raw pointer, so in the
> > long run we could consider rewriting some of these messages as
> > tracepoints.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> It sucks to have to play games like this, but we have to be able to
> debug the code somehow....
> 
> > diff --git a/fs/xfs/xfs_linux.h b/fs/xfs/xfs_linux.h
> > index fd03780..0949bab 100644
> > --- a/fs/xfs/xfs_linux.h
> > +++ b/fs/xfs/xfs_linux.h
> > @@ -291,4 +291,10 @@ static inline uint64_t howmany_64(uint64_t x, uint32_t y)
> >  #define XFS_IS_REALTIME_MOUNT(mp) (0)
> >  #endif
> >  
> > +#ifdef DEBUG
> > +# define PTR_FMT "%px"
> > +#else
> > +# define PTR_FMT "%p"
> > +#endif
> 
> Can you add a comment here explaining why this is different?

/*
 * Starting in Linux 4.15, the %p (raw pointer value) printk modifier
 * prints a hashed version of the pointer to avoid leaking kernel
 * pointers into dmesg.  If we're trying to debug the kernel we want the
 * raw values, so override this behavior as best we can.
 */

--D

> 
> Otherwise it looks OK.
> 
> Reviewed-by: Dave Chinner <dchinner@redhat.com>
> -- 
> Dave Chinner
> david@fromorbit.com
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

      reply	other threads:[~2018-01-09 23:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-09 20:45 [PATCH 0/3] xfs: printk fixes Darrick J. Wong
2018-01-09 20:45 ` [PATCH 1/3] xfs: change 0x%p -> %p in print messages Darrick J. Wong
2018-01-09 22:59   ` Dave Chinner
2018-01-09 20:46 ` [PATCH 2/3] xfs: use %pS printk format for direct instruction addresses Darrick J. Wong
2018-01-09 23:01   ` Dave Chinner
2018-01-09 20:46 ` [PATCH 3/3] xfs: use %px for data pointers when debugging Darrick J. Wong
2018-01-09 23:04   ` Dave Chinner
2018-01-09 23:16     ` Darrick J. Wong [this message]

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=20180109231646.GQ5602@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=linux-xfs@vger.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.