File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 31
31
/*
32
32
* Relay buffer statistics
33
33
*/
34
+ enum {
35
+ RELAY_STATS_BUF_FULL = (1 << 0 ),
36
+
37
+ RELAY_STATS_LAST = RELAY_STATS_BUF_FULL ,
38
+ };
39
+
34
40
struct rchan_buf_stats
35
41
{
36
42
unsigned int full_count ; /* counter for buffer full */
@@ -167,6 +173,7 @@ struct rchan *relay_open(const char *base_filename,
167
173
void * private_data );
168
174
extern void relay_close (struct rchan * chan );
169
175
extern void relay_flush (struct rchan * chan );
176
+ size_t relay_stats (struct rchan * chan , int flags );
170
177
extern void relay_subbufs_consumed (struct rchan * chan ,
171
178
unsigned int cpu ,
172
179
size_t consumed );
Original file line number Diff line number Diff line change @@ -700,6 +700,36 @@ void relay_flush(struct rchan *chan)
700
700
}
701
701
EXPORT_SYMBOL_GPL (relay_flush );
702
702
703
+ /**
704
+ * relay_stats - get channel buffer statistics
705
+ * @chan: the channel
706
+ * @flags: select particular information to get
707
+ *
708
+ * Returns the count of certain field that caller specifies.
709
+ */
710
+ size_t relay_stats (struct rchan * chan , int flags )
711
+ {
712
+ unsigned int i , count = 0 ;
713
+ struct rchan_buf * rbuf ;
714
+
715
+ if (!chan || flags > RELAY_STATS_LAST )
716
+ return 0 ;
717
+
718
+ if (chan -> is_global ) {
719
+ rbuf = * per_cpu_ptr (chan -> buf , 0 );
720
+ if (flags & RELAY_STATS_BUF_FULL )
721
+ count = rbuf -> stats .full_count ;
722
+ } else {
723
+ for_each_online_cpu (i ) {
724
+ rbuf = * per_cpu_ptr (chan -> buf , i );
725
+ if (rbuf && flags & RELAY_STATS_BUF_FULL )
726
+ count += rbuf -> stats .full_count ;
727
+ }
728
+ }
729
+
730
+ return count ;
731
+ }
732
+
703
733
/**
704
734
* relay_file_open - open file op for relay files
705
735
* @inode: the inode
You can’t perform that action at this time.
0 commit comments