[ltt-dev] Odd behaviour of setMarkerEnable

Thibault, Daniel Daniel.Thibault at drdc-rddc.gc.ca
Thu Jul 21 16:48:55 EDT 2011


   The ltt_control command "setMarkerEnable" allows one to (globally) enable or disable a marker on the target machine through a line like:

 

> tcf ltt_control setMarkerEnable "kernel" "0" "irq_state/interrupt" true

 

   However, if one tries to enable an already-enabled marker, one gets:

 

{"Code":1,"Time":1311277723370,"Format":"Unknown error 131073"} "Kernel : Can't enable marker irq_state/interrupt : File exists"

 

   Similarly, if one tries to disable an already-disabled marker, one gets:

 

{"Code":1,"Time":1311278390400,"Format":"Unknown error 131073"} "Kernel : Can't enable marker irq_state/interrupt : No such file or directory"

 

   The expected behaviour in both cases is a simple success.  There is no reason for the errors.

 

   What's remarkable here is that the errors are at once the same (same unknown error code) and different ("File exists" vs. " No such file or directory").  I've narrowed down the problem to the LTTng TCF agent plug-in's lttctlkerninterface.c and the methods ltt_kern_set_marker_enable and ltt_kern_sendop.  The former prepares the target file name for the latter.  The enabled/disabled state of the marker is managed through the /sys/kernel/debug/ltt/markers/irq_state/interrupt/enable file, which contains "1" or "0".

 

   I'm really puzzled by this bug: the behaviour is deterministically consistent but the error messages make no sense (the target file is never missing, and what of the "File exists" message??).

 

   The offending code is:

 

static int ltt_kern_sendop(const char *fname, const char *op)

{

    int fd;

 

    if (!fname) {

        fprintf(stderr, "%s: args invalid\n", __func__);

        return 1;

    }

 

    fd = open(fname, O_WRONLY);

    if (fd == -1) {

        fprintf(stderr, "%s: open %s failed: %s\n", __func__, fname, strerror(errno));

        return errno;

    }

 

    if (write(fd, op, strlen(op)) == -1) {

        int ret = errno;

        fprintf(stderr, "%s: write %s to %s failed: %s\n", __func__, op, fname, strerror(errno));

        close(fd);

        return ret;

    }

 

    close(fd);

    return 0;

}

 

   The write(fd, op, strlen(op)) fails in both the double-enabling ("write 1 to /sys/kernel/debug/ltt/markers/irq_state/interrupt/enable failed: File exists") and double-disabling ("write 0 to /sys/kernel/debug/ltt/markers/irq_state/interrupt/enable failed: No such file or directory") cases.

 

   Anyone have a clue what is going on?

 

Daniel U. Thibault
R & D pour la défense Canada - Valcartier (RDDC Valcartier) / Defence R&D Canada - Valcartier (DRDC Valcartier)
Système de systèmes (SdS) / System of Systems (SoS)
Solutions informatiques et expérimentations (SIE) / Computing Solutions and Experimentations (CSE)
2459 Boul. Pie XI Nord
Québec, QC  G3J 1X5
CANADA
Vox : (418) 844-4000 x4245
Fax : (418) 844-4538

NAC: 918V QSDJ <http://www.travelgis.com/map.asp?addr=918V%20QSDJ> 
Gouvernement du Canada / Government of Canada
<http://www.valcartier.drdc-rddc.gc.ca/ <http://www.valcartier.drdc-rddc.gc.ca/> >

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.casi.polymtl.ca/pipermail/lttng-dev/attachments/20110721/d1ea9dc0/attachment-0002.htm>


More information about the lttng-dev mailing list