misc: tegra-profiler: reduce size of sample
Igor Nabirushkin [Mon, 27 Jan 2014 10:08:51 +0000 (14:08 +0400)]
Tegra Profiler: reduce size of sample
magic number was removed

Bug 1447839

Change-Id: I14a23f668eab575add872daa35f27653eff643ff
Signed-off-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-on: http://git-master/r/360353
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>

drivers/misc/tegra-profiler/comm.c
drivers/misc/tegra-profiler/hrt.c
drivers/misc/tegra-profiler/ma.c
drivers/misc/tegra-profiler/mmap.c
drivers/misc/tegra-profiler/power_clk.c
drivers/misc/tegra-profiler/version.h
include/linux/tegra_profiler.h

index 98f17a2..e94bcbf 100644 (file)
@@ -267,23 +267,18 @@ static ssize_t read_sample(char __user *buffer, size_t max_length)
                goto out;
        }
 
-       if (rb->fill_count < sizeof(struct quadd_record_data))
+       if (rb->fill_count < sizeof(record))
                goto out;
 
-       if (!rb_read(rb, (char *)&record, sizeof(struct quadd_record_data)))
+       if (!rb_read(rb, (char *)&record, sizeof(record)))
                goto out;
 
-       if (record.magic != QUADD_RECORD_MAGIC) {
-               pr_err("Error: bad magic: %#x\n", record.magic);
-               goto out;
-       }
-
        switch (record.record_type) {
        case QUADD_RECORD_TYPE_SAMPLE:
                sample = &record.sample;
                length_extra = sample->callchain_nr * sizeof(quadd_bt_addr_t);
 
-               nr_events = __sw_hweight32(record.sample.events_flags);
+               nr_events = __sw_hweight32(sample->events_flags);
                length_extra += nr_events * sizeof(u32);
 
                length_extra += sample->state ? sizeof(u32) : 0;
@@ -324,8 +319,8 @@ static ssize_t read_sample(char __user *buffer, size_t max_length)
                goto out;
        }
 
-       if (sizeof(struct quadd_record_data) + length_extra > max_length) {
-               retval = rb_read_undo(rb, sizeof(struct quadd_record_data));
+       if (sizeof(record) + length_extra > max_length) {
+               retval = rb_read_undo(rb, sizeof(record));
                if (retval < 0)
                        goto out;
 
@@ -336,7 +331,7 @@ static ssize_t read_sample(char __user *buffer, size_t max_length)
        if (length_extra > rb->fill_count)
                goto out;
 
-       if (copy_to_user(buffer, &record, sizeof(struct quadd_record_data)))
+       if (copy_to_user(buffer, &record, sizeof(record)))
                goto out_fault_error;
 
        if (length_extra > 0) {
@@ -347,7 +342,7 @@ static ssize_t read_sample(char __user *buffer, size_t max_length)
        }
 
        spin_unlock_irqrestore(&rb->lock, flags);
-       return sizeof(struct quadd_record_data) + length_extra;
+       return sizeof(record) + length_extra;
 
 out_fault_error:
        retval = -EFAULT;
index 88d91c3..b025f52 100644 (file)
@@ -113,7 +113,6 @@ static void put_header(void)
        struct quadd_event_source_interface *pmu = ctx->pmu;
        struct quadd_event_source_interface *pl310 = ctx->pl310;
 
-       record.magic = QUADD_RECORD_MAGIC;
        record.record_type = QUADD_RECORD_TYPE_HEADER;
 
        hdr->magic = QUADD_HEADER_MAGIC;
@@ -306,7 +305,6 @@ read_all_sources(struct pt_regs *regs, struct task_struct *task)
        }
        s->callchain_nr = bt_size;
 
-       record_data.magic = QUADD_RECORD_MAGIC;
        record_data.record_type = QUADD_RECORD_TYPE_SAMPLE;
 
        s->events_flags = 0;
index adc6c03..91b2879 100644 (file)
@@ -37,7 +37,6 @@ static void make_sample(struct quadd_hrt_ctx *hrt_ctx,
        struct quadd_ma_data *ma = &record.ma;
        struct quadd_comm_data_interface *comm = hrt_ctx->quadd_ctx->comm;
 
-       record.magic = QUADD_RECORD_MAGIC;
        record.record_type = QUADD_RECORD_TYPE_MA;
 
        ma->pid = pid;
index cb513bf..9e7c776 100644 (file)
@@ -36,7 +36,6 @@ put_mmap_sample(struct quadd_mmap_data *s, char *filename,
        struct quadd_iovec vec[2];
        u64 pgoff_val = pgoff << PAGE_SHIFT;
 
-       r.magic = QUADD_RECORD_MAGIC;
        r.record_type = QUADD_RECORD_TYPE_MMAP;
 
        memcpy(&r.mmap, s, sizeof(*s));
index 261cf87..d928aca 100644 (file)
@@ -162,7 +162,6 @@ static void make_sample(void)
        struct quadd_power_rate_data *power_rate = &record.power_rate;
        struct quadd_comm_data_interface *comm = power_ctx.quadd_ctx->comm;
 
-       record.magic = QUADD_RECORD_MAGIC;
        record.record_type = QUADD_RECORD_TYPE_POWER_RATE;
 
        power_rate->time = quadd_get_time();
index 46643a2..97d0a51 100644 (file)
@@ -18,7 +18,7 @@
 #ifndef __QUADD_VERSION_H
 #define __QUADD_VERSION_H
 
-#define QUADD_MODULE_VERSION           "1.48"
+#define QUADD_MODULE_VERSION           "1.51"
 #define QUADD_MODULE_BRANCH            "Dev"
 
 #endif /* __QUADD_VERSION_H */
index 15205e7..9a7299e 100644 (file)
@@ -19,7 +19,7 @@
 
 #include <linux/ioctl.h>
 
-#define QUADD_SAMPLES_VERSION  20
+#define QUADD_SAMPLES_VERSION  21
 #define QUADD_IO_VERSION       9
 
 #define QUADD_IO_VERSION_DYNAMIC_RB            5
@@ -236,12 +236,10 @@ struct quadd_header_data {
        u16 extra_length;
 };
 
-#define QUADD_RECORD_MAGIC     0x335577aa
-
 struct quadd_record_data {
-       u32 magic;      /* temporary, it will be removed later */
        u8 record_type;
 
+       /* sample: it should be the biggest size */
        union {
                struct quadd_sample_data        sample;
                struct quadd_mmap_data          mmap;