Ignore:
Timestamp:
10/03/13 23:46:37 (11 years ago)
Author:
atzm
Message:

optimize stats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ksyslog/trunk/ksyslog.h

    r249 r250  
    7272}; 
    7373 
     74struct ksyslog_stats { 
     75        u64 write_bytes; 
     76        u64 write_packets; 
     77        u64 drop_bytes; 
     78        u64 drop_packets; 
     79        u64 discard_bytes; 
     80        u64 discard_packets; 
     81        struct u64_stats_sync sync; 
     82}; 
     83 
    7484struct ksyslog_queue { 
    7585        struct list_head head; 
    7686        spinlock_t lock; 
    77         atomic64_t nr_queued; 
    78         atomic64_t nr_written; 
    79         atomic64_t nr_dropped; 
    80 }; 
     87        atomic64_t size; 
     88        struct ksyslog_stats __percpu *stats; 
     89}; 
     90 
     91static inline void 
     92ksyslog_stats_add_write(struct ksyslog_queue *queue, unsigned int len) 
     93{ 
     94        struct ksyslog_stats *stats; 
     95 
     96        stats = per_cpu_ptr(queue->stats, smp_processor_id()); 
     97        u64_stats_update_begin(&stats->sync); 
     98        stats->write_bytes += len; 
     99        stats->write_packets++; 
     100        u64_stats_update_end(&stats->sync); 
     101} 
     102 
     103static inline void 
     104ksyslog_stats_add_drop(struct ksyslog_queue *queue, unsigned int len) 
     105{ 
     106        struct ksyslog_stats *stats; 
     107 
     108        stats = per_cpu_ptr(queue->stats, smp_processor_id()); 
     109        u64_stats_update_begin(&stats->sync); 
     110        stats->drop_bytes += len; 
     111        stats->drop_packets++; 
     112        u64_stats_update_end(&stats->sync); 
     113} 
     114 
     115static inline void 
     116ksyslog_stats_add_discard(struct ksyslog_queue *queue, unsigned int len) 
     117{ 
     118        struct ksyslog_stats *stats; 
     119 
     120        stats = per_cpu_ptr(queue->stats, smp_processor_id()); 
     121        u64_stats_update_begin(&stats->sync); 
     122        stats->discard_bytes += len; 
     123        stats->discard_packets++; 
     124        u64_stats_update_end(&stats->sync); 
     125} 
    81126 
    82127static inline const char * 
Note: See TracChangeset for help on using the changeset viewer.