Ignore:
Timestamp:
05/16/14 00:29:33 (10 years ago)
Author:
atzm
Message:

improve performance on multi-queue environment

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ksyslog/trunk/ksyslog.h

    r250 r271  
    7373 
    7474struct 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; 
     75        atomic64_t bytes; 
     76        atomic64_t packets; 
    8277}; 
    8378 
    8479struct ksyslog_queue { 
    8580        struct list_head head; 
     81        struct work_struct work; 
    8682        spinlock_t lock; 
    8783        atomic64_t size; 
    88         struct ksyslog_stats __percpu *stats; 
     84        struct ksyslog_stats write_stats; 
     85        struct ksyslog_stats drop_stats; 
     86        struct ksyslog_stats discard_stats; 
    8987}; 
    9088 
    9189static inline void 
    92 ksyslog_stats_add_write(struct ksyslog_queue *queue, unsigned int len) 
     90ksyslog_stats_zero(struct ksyslog_stats *stats) 
    9391{ 
    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); 
     92        atomic64_set(&stats->bytes, 0); 
     93        atomic64_set(&stats->packets, 0); 
    10194} 
    10295 
    10396static inline void 
    104 ksyslog_stats_add_drop(struct ksyslog_queue *queue, unsigned int len) 
     97ksyslog_stats_add(struct ksyslog_stats *stats, unsigned int len) 
    10598{ 
    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  
    115 static inline void 
    116 ksyslog_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); 
     99        atomic64_add(len, &stats->bytes); 
     100        atomic64_inc(&stats->packets); 
    125101} 
    126102 
Note: See TracChangeset for help on using the changeset viewer.