Project

General

Profile

Bug #3470

::whatis does not print callers from KMF_LITE

Added by Christopher Siden almost 8 years ago. Updated almost 8 years ago.

Status:
Resolved
Priority:
Normal
Category:
cmd - userland programs
Start date:
2013-01-11
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:

Description

From Matt Ahrens's original bug report at Delphix:

::whatis on a buffer from a KMF_LITE cache is supposed to print the recent
callers (recorded in kmem_buftag_lite_t's bt_history).  This should be done by
whatis_print_kmf_lite().  However, this function does not seem to be compiled
correctly; it always returns after the first mdb_vread:

$ echo whatis_print_kmf_lite::dis | mdb /usr/lib/mdb/kvm/amd64/genunix.so
whatis_print_kmf_lite:          pushq  %rbp
whatis_print_kmf_lite+1:        movq   %rsp,%rbp
whatis_print_kmf_lite+4:        subq   $0x20,%rsp
whatis_print_kmf_lite+8:        testq  %rsi,%rsi
whatis_print_kmf_lite+0xb:      je     +0x22    <whatis_print_kmf_lite+0x2f>
whatis_print_kmf_lite+0xd:      movq   $0x10,%r8
whatis_print_kmf_lite+0x14:     cmpq   %rsi,%r8
whatis_print_kmf_lite+0x17:     jb     +0x16    <whatis_print_kmf_lite+0x2f>
whatis_print_kmf_lite+0x19:     leaq   -0x20(%rbp),%r8
whatis_print_kmf_lite+0x1d:     movq   %rdi,%rdx
whatis_print_kmf_lite+0x20:     movq   %r8,%rdi
whatis_print_kmf_lite+0x23:     movq   $0x18,%rsi
whatis_print_kmf_lite+0x2a:     call   -0x19d27 <PLT:mdb_vread>
whatis_print_kmf_lite+0x2f:     leave  
whatis_print_kmf_lite+0x30:     ret

------------

Actually the compiler is correctly optimizing this code:

      if (stat != KMEM_BUFTAG_ALLOC || stat != KMEM_BUFTAG_FREE || ... )
         return;

since KMEM_BUFTAG_ALLOC and KMEM_BUFTAG_FREE are not the same, this must always
be true.

It should be something like:

    if (stat != KMEM_BUFTAG_ALLOC && stat != KMEM_BUFTAG_FREE)
        return;

This has been broken since the last ::whatis rewrite, in 2009:

commit 4a1c24318fe7c9bdae38ce58a2e4624597d297e2
Author: Jonathan Adams <Jonathan.Adams@Sun.COM>
Date:   Tue Sep 22 13:42:17 2009 -0700

    6881824 ::whatis needs to be faster, smarter, and modular
#1

Updated by Christopher Siden almost 8 years ago

  • Status changed from Pending RTI to Resolved
  • % Done changed from 0 to 100
commit 28e4da2
Author: Matthew Ahrens <mahrens@delphix.com>
Date:   Wed Jan 30 15:02:58 2013

    3465 ::walk ... | ::<dcmd> misinterprets input as symbol names
    3466 ::tsd should handle missing/NULL values better
    3467 mdb_ctf_vread() could be more useful
    3468 mdb enhancements for zfs development
    3470 ::whatis does not print callers from KMF_LITE
    3473 mdb_get_module() returns wrong module
    Reviewed by: Adam Leventhal <ahl@delphix.com>
    Reviewed by: Eric Schrock <eric.schrock@delphix.com>
    Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Approved by: Dan McDonald <danmcd@nexenta.com>

Also available in: Atom PDF