Merge branch 'tracing-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 7 Apr 2009 21:10:10 +0000 (14:10 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 7 Apr 2009 21:10:10 +0000 (14:10 -0700)
* 'tracing-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  branch tracer, intel-iommu: fix build with CONFIG_BRANCH_TRACER=y
  branch tracer: Fix for enabling branch profiling makes sparse unusable
  ftrace: Correct a text align for event format output
  Update /debug/tracing/README
  tracing/ftrace: alloc the started cpumask for the trace file
  tracing, x86: remove duplicated #include
  ftrace: Add check of sched_stopped for probe_sched_wakeup
  function-graph: add proper initialization for init task
  tracing/ftrace: fix missing include string.h
  tracing: fix incorrect return type of ns2usecs()
  tracing: remove CALLER_ADDR2 from wakeup tracer
  blktrace: fix pdu_len when tracing packet command requests
  blktrace: small cleanup in blk_msg_write()
  blktrace: NUL-terminate user space messages
  tracing: move scripts/trace/power.pl to scripts/tracing/power.pl

1  2 
block/blk-core.c
include/linux/init_task.h
kernel/trace/trace.h

diff --combined block/blk-core.c
@@@ -64,11 -64,12 +64,11 @@@ static struct workqueue_struct *kblockd
  
  static void drive_stat_acct(struct request *rq, int new_io)
  {
 -      struct gendisk *disk = rq->rq_disk;
        struct hd_struct *part;
        int rw = rq_data_dir(rq);
        int cpu;
  
 -      if (!blk_fs_request(rq) || !disk || !blk_do_io_stat(disk->queue))
 +      if (!blk_fs_request(rq) || !blk_do_io_stat(rq))
                return;
  
        cpu = part_stat_lock();
@@@ -131,6 -132,7 +131,7 @@@ void blk_rq_init(struct request_queue *
        INIT_HLIST_NODE(&rq->hash);
        RB_CLEAR_NODE(&rq->rb_node);
        rq->cmd = rq->__cmd;
+       rq->cmd_len = BLK_MAX_CDB;
        rq->tag = -1;
        rq->ref_count = 1;
  }
@@@ -483,11 -485,11 +484,11 @@@ static int blk_init_free_list(struct re
  {
        struct request_list *rl = &q->rq;
  
 -      rl->count[READ] = rl->count[WRITE] = 0;
 -      rl->starved[READ] = rl->starved[WRITE] = 0;
 +      rl->count[BLK_RW_SYNC] = rl->count[BLK_RW_ASYNC] = 0;
 +      rl->starved[BLK_RW_SYNC] = rl->starved[BLK_RW_ASYNC] = 0;
        rl->elvpriv = 0;
 -      init_waitqueue_head(&rl->wait[READ]);
 -      init_waitqueue_head(&rl->wait[WRITE]);
 +      init_waitqueue_head(&rl->wait[BLK_RW_SYNC]);
 +      init_waitqueue_head(&rl->wait[BLK_RW_ASYNC]);
  
        rl->rq_pool = mempool_create_node(BLKDEV_MIN_RQ, mempool_alloc_slab,
                                mempool_free_slab, request_cachep, q->node);
@@@ -602,10 -604,13 +603,10 @@@ blk_init_queue_node(request_fn_proc *rf
        q->queue_flags          = QUEUE_FLAG_DEFAULT;
        q->queue_lock           = lock;
  
 -      blk_queue_segment_boundary(q, BLK_SEG_BOUNDARY_MASK);
 -
 +      /*
 +       * This also sets hw/phys segments, boundary and size
 +       */
        blk_queue_make_request(q, __make_request);
 -      blk_queue_max_segment_size(q, MAX_SEGMENT_SIZE);
 -
 -      blk_queue_max_hw_segments(q, MAX_HW_SEGMENTS);
 -      blk_queue_max_phys_segments(q, MAX_PHYS_SEGMENTS);
  
        q->sg_reserved_size = INT_MAX;
  
@@@ -698,18 -703,18 +699,18 @@@ static void ioc_set_batching(struct req
        ioc->last_waited = jiffies;
  }
  
 -static void __freed_request(struct request_queue *q, int rw)
 +static void __freed_request(struct request_queue *q, int sync)
  {
        struct request_list *rl = &q->rq;
  
 -      if (rl->count[rw] < queue_congestion_off_threshold(q))
 -              blk_clear_queue_congested(q, rw);
 +      if (rl->count[sync] < queue_congestion_off_threshold(q))
 +              blk_clear_queue_congested(q, sync);
  
 -      if (rl->count[rw] + 1 <= q->nr_requests) {
 -              if (waitqueue_active(&rl->wait[rw]))
 -                      wake_up(&rl->wait[rw]);
 +      if (rl->count[sync] + 1 <= q->nr_requests) {
 +              if (waitqueue_active(&rl->wait[sync]))
 +                      wake_up(&rl->wait[sync]);
  
 -              blk_clear_queue_full(q, rw);
 +              blk_clear_queue_full(q, sync);
        }
  }
  
   * A request has just been released.  Account for it, update the full and
   * congestion status, wake up any waiters.   Called under q->queue_lock.
   */
 -static void freed_request(struct request_queue *q, int rw, int priv)
 +static void freed_request(struct request_queue *q, int sync, int priv)
  {
        struct request_list *rl = &q->rq;
  
 -      rl->count[rw]--;
 +      rl->count[sync]--;
        if (priv)
                rl->elvpriv--;
  
 -      __freed_request(q, rw);
 +      __freed_request(q, sync);
  
 -      if (unlikely(rl->starved[rw ^ 1]))
 -              __freed_request(q, rw ^ 1);
 +      if (unlikely(rl->starved[sync ^ 1]))
 +              __freed_request(q, sync ^ 1);
  }
  
 -#define blkdev_free_rq(list) list_entry((list)->next, struct request, queuelist)
  /*
   * Get a free request, queue_lock must be held.
   * Returns NULL on failure, with queue_lock held.
@@@ -742,15 -748,15 +743,15 @@@ static struct request *get_request(stru
        struct request *rq = NULL;
        struct request_list *rl = &q->rq;
        struct io_context *ioc = NULL;
 -      const int rw = rw_flags & 0x01;
 +      const bool is_sync = rw_is_sync(rw_flags) != 0;
        int may_queue, priv;
  
        may_queue = elv_may_queue(q, rw_flags);
        if (may_queue == ELV_MQUEUE_NO)
                goto rq_starved;
  
 -      if (rl->count[rw]+1 >= queue_congestion_on_threshold(q)) {
 -              if (rl->count[rw]+1 >= q->nr_requests) {
 +      if (rl->count[is_sync]+1 >= queue_congestion_on_threshold(q)) {
 +              if (rl->count[is_sync]+1 >= q->nr_requests) {
                        ioc = current_io_context(GFP_ATOMIC, q->node);
                        /*
                         * The queue will fill after this allocation, so set
                         * This process will be allowed to complete a batch of
                         * requests, others will be blocked.
                         */
 -                      if (!blk_queue_full(q, rw)) {
 +                      if (!blk_queue_full(q, is_sync)) {
                                ioc_set_batching(q, ioc);
 -                              blk_set_queue_full(q, rw);
 +                              blk_set_queue_full(q, is_sync);
                        } else {
                                if (may_queue != ELV_MQUEUE_MUST
                                                && !ioc_batching(q, ioc)) {
                                }
                        }
                }
 -              blk_set_queue_congested(q, rw);
 +              blk_set_queue_congested(q, is_sync);
        }
  
        /*
         * limit of requests, otherwise we could have thousands of requests
         * allocated with any setting of ->nr_requests
         */
 -      if (rl->count[rw] >= (3 * q->nr_requests / 2))
 +      if (rl->count[is_sync] >= (3 * q->nr_requests / 2))
                goto out;
  
 -      rl->count[rw]++;
 -      rl->starved[rw] = 0;
 +      rl->count[is_sync]++;
 +      rl->starved[is_sync] = 0;
  
        priv = !test_bit(QUEUE_FLAG_ELVSWITCH, &q->queue_flags);
        if (priv)
                 * wait queue, but this is pretty rare.
                 */
                spin_lock_irq(q->queue_lock);
 -              freed_request(q, rw, priv);
 +              freed_request(q, is_sync, priv);
  
                /*
                 * in the very unlikely event that allocation failed and no
                 * rq mempool into READ and WRITE
                 */
  rq_starved:
 -              if (unlikely(rl->count[rw] == 0))
 -                      rl->starved[rw] = 1;
 +              if (unlikely(rl->count[is_sync] == 0))
 +                      rl->starved[is_sync] = 1;
  
                goto out;
        }
        if (ioc_batching(q, ioc))
                ioc->nr_batch_requests--;
  
 -      trace_block_getrq(q, bio, rw);
 +      trace_block_getrq(q, bio, rw_flags & 1);
  out:
        return rq;
  }
  static struct request *get_request_wait(struct request_queue *q, int rw_flags,
                                        struct bio *bio)
  {
 -      const int rw = rw_flags & 0x01;
 +      const bool is_sync = rw_is_sync(rw_flags) != 0;
        struct request *rq;
  
        rq = get_request(q, rw_flags, bio, GFP_NOIO);
                struct io_context *ioc;
                struct request_list *rl = &q->rq;
  
 -              prepare_to_wait_exclusive(&rl->wait[rw], &wait,
 +              prepare_to_wait_exclusive(&rl->wait[is_sync], &wait,
                                TASK_UNINTERRUPTIBLE);
  
 -              trace_block_sleeprq(q, bio, rw);
 +              trace_block_sleeprq(q, bio, rw_flags & 1);
  
                __generic_unplug_device(q);
                spin_unlock_irq(q->queue_lock);
                ioc_set_batching(q, ioc);
  
                spin_lock_irq(q->queue_lock);
 -              finish_wait(&rl->wait[rw], &wait);
 +              finish_wait(&rl->wait[is_sync], &wait);
  
                rq = get_request(q, rw_flags, bio, GFP_NOIO);
        };
@@@ -1061,22 -1067,19 +1062,22 @@@ void __blk_put_request(struct request_q
  
        elv_completed_request(q, req);
  
 +      /* this is a bio leak */
 +      WARN_ON(req->bio != NULL);
 +
        /*
         * Request may not have originated from ll_rw_blk. if not,
         * it didn't come out of our reserved rq pools
         */
        if (req->cmd_flags & REQ_ALLOCED) {
 -              int rw = rq_data_dir(req);
 +              int is_sync = rq_is_sync(req) != 0;
                int priv = req->cmd_flags & REQ_ELVPRIV;
  
                BUG_ON(!list_empty(&req->queuelist));
                BUG_ON(!hlist_unhashed(&req->hash));
  
                blk_free_request(q, req);
 -              freed_request(q, rw, priv);
 +              freed_request(q, is_sync, priv);
        }
  }
  EXPORT_SYMBOL_GPL(__blk_put_request);
@@@ -1123,10 -1126,10 +1124,10 @@@ void init_request_from_bio(struct reque
  
        if (bio_sync(bio))
                req->cmd_flags |= REQ_RW_SYNC;
 -      if (bio_unplug(bio))
 -              req->cmd_flags |= REQ_UNPLUG;
        if (bio_rw_meta(bio))
                req->cmd_flags |= REQ_RW_META;
 +      if (bio_noidle(bio))
 +              req->cmd_flags |= REQ_NOIDLE;
  
        req->errors = 0;
        req->hard_sector = req->sector = bio->bi_sector;
        blk_rq_bio_prep(req->q, req, bio);
  }
  
 +/*
 + * Only disabling plugging for non-rotational devices if it does tagging
 + * as well, otherwise we do need the proper merging
 + */
 +static inline bool queue_should_plug(struct request_queue *q)
 +{
 +      return !(blk_queue_nonrot(q) && blk_queue_tagged(q));
 +}
 +
  static int __make_request(struct request_queue *q, struct bio *bio)
  {
        struct request *req;
@@@ -1250,11 -1244,11 +1251,11 @@@ get_rq
        if (test_bit(QUEUE_FLAG_SAME_COMP, &q->queue_flags) ||
            bio_flagged(bio, BIO_CPU_AFFINE))
                req->cpu = blk_cpu_to_group(smp_processor_id());
 -      if (!blk_queue_nonrot(q) && elv_queue_empty(q))
 +      if (queue_should_plug(q) && elv_queue_empty(q))
                blk_plug_device(q);
        add_request(q, req);
  out:
 -      if (unplug || blk_queue_nonrot(q))
 +      if (unplug || !queue_should_plug(q))
                __generic_unplug_device(q);
        spin_unlock_irq(q->queue_lock);
        return 0;
@@@ -1672,7 -1666,9 +1673,7 @@@ EXPORT_SYMBOL(blkdev_dequeue_request)
  
  static void blk_account_io_completion(struct request *req, unsigned int bytes)
  {
 -      struct gendisk *disk = req->rq_disk;
 -
 -      if (!disk || !blk_do_io_stat(disk->queue))
 +      if (!blk_do_io_stat(req))
                return;
  
        if (blk_fs_request(req)) {
  
  static void blk_account_io_done(struct request *req)
  {
 -      struct gendisk *disk = req->rq_disk;
 -
 -      if (!disk || !blk_do_io_stat(disk->queue))
 +      if (!blk_do_io_stat(req))
                return;
  
        /*
                int cpu;
  
                cpu = part_stat_lock();
 -              part = disk_map_sector_rcu(disk, req->sector);
 +              part = disk_map_sector_rcu(req->rq_disk, req->sector);
  
                part_stat_inc(cpu, part, ios[rw]);
                part_stat_add(cpu, part, ticks[rw], duration);
@@@ -5,6 -5,7 +5,7 @@@
  #include <linux/irqflags.h>
  #include <linux/utsname.h>
  #include <linux/lockdep.h>
+ #include <linux/ftrace.h>
  #include <linux/ipc.h>
  #include <linux/pid_namespace.h>
  #include <linux/user_namespace.h>
@@@ -147,7 -148,6 +148,7 @@@ extern struct cred init_cred
                .nr_cpus_allowed = NR_CPUS,                             \
        },                                                              \
        .tasks          = LIST_HEAD_INIT(tsk.tasks),                    \
 +      .pushable_tasks = PLIST_NODE_INIT(tsk.pushable_tasks, MAX_PRIO), \
        .ptraced        = LIST_HEAD_INIT(tsk.ptraced),                  \
        .ptrace_entry   = LIST_HEAD_INIT(tsk.ptrace_entry),             \
        .real_parent    = &tsk,                                         \
        INIT_IDS                                                        \
        INIT_TRACE_IRQFLAGS                                             \
        INIT_LOCKDEP                                                    \
+       INIT_FTRACE_GRAPH                                               \
  }
  
  
diff --combined kernel/trace/trace.h
@@@ -182,12 -182,6 +182,12 @@@ struct trace_power 
        struct power_trace      state_data;
  };
  
 +enum kmemtrace_type_id {
 +      KMEMTRACE_TYPE_KMALLOC = 0,     /* kmalloc() or kfree(). */
 +      KMEMTRACE_TYPE_CACHE,           /* kmem_cache_*(). */
 +      KMEMTRACE_TYPE_PAGES,           /* __get_free_pages() and friends. */
 +};
 +
  struct kmemtrace_alloc_entry {
        struct trace_entry      ent;
        enum kmemtrace_type_id type_id;
@@@ -602,7 -596,7 +602,7 @@@ extern int trace_selftest_startup_branc
  #endif /* CONFIG_FTRACE_STARTUP_TEST */
  
  extern void *head_page(struct trace_array_cpu *data);
- extern long ns2usecs(cycle_t nsec);
+ extern unsigned long long ns2usecs(cycle_t nsec);
  extern int
  trace_vbprintk(unsigned long ip, const char *fmt, va_list args);
  extern int