scoutfs: add tracepoint support with bloom example

Add the intrastucture for tracepoints.  We include an example user that
traces bloom filter hits and misses.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2016-03-26 20:58:31 -07:00
parent 9cf87ee571
commit 402dd2969f
6 changed files with 121 additions and 2 deletions

View File

@@ -1,4 +1,6 @@
obj-$(CONFIG_SCOUTFS_FS) := scoutfs.o
CFLAGS_scoutfs_trace.o = -I$(src) # define_trace.h double include
scoutfs-y += block.o bloom.o chunk.o crc.o dir.o filerw.o inode.o manifest.o \
msg.o ring.o segment.o skip.o super.o
msg.o ring.o scoutfs_trace.o segment.o skip.o super.o

View File

@@ -20,6 +20,7 @@
#include "format.h"
#include "block.h"
#include "bloom.h"
#include "scoutfs_trace.h"
/*
* Each log segment starts with a bloom filters that spans multiple
@@ -100,6 +101,7 @@ int scoutfs_set_bloom_bits(struct super_block *sb, u64 blkno,
* might, and -errno if IO fails.
*/
int scoutfs_test_bloom_bits(struct super_block *sb, u64 blkno,
struct scoutfs_key *key,
struct scoutfs_bloom_bits *bits)
{
struct scoutfs_bloom_block *blm;
@@ -121,5 +123,10 @@ int scoutfs_test_bloom_bits(struct super_block *sb, u64 blkno,
break;
}
if (ret)
trace_scoutfs_bloom_hit(key);
else
trace_scoutfs_bloom_miss(key);
return ret;
}

View File

@@ -9,6 +9,7 @@ struct scoutfs_bloom_bits {
void scoutfs_calc_bloom_bits(struct scoutfs_bloom_bits *bits,
struct scoutfs_key *key, __le32 *salts);
int scoutfs_test_bloom_bits(struct super_block *sb, u64 blkno,
struct scoutfs_key *key,
struct scoutfs_bloom_bits *bits);
int scoutfs_set_bloom_bits(struct super_block *sb, u64 blkno,
struct scoutfs_bloom_bits *bits);

32
kmod/src/scoutfs_trace.c Normal file
View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2016 Versity Software, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License v2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/magic.h>
#include <linux/buffer_head.h>
#include <linux/random.h>
#include "super.h"
#include "format.h"
#include "inode.h"
#include "dir.h"
#include "msg.h"
#include "block.h"
#include "manifest.h"
#include "ring.h"
#include "segment.h"
#define CREATE_TRACE_POINTS
#include "scoutfs_trace.h"

77
kmod/src/scoutfs_trace.h Normal file
View File

@@ -0,0 +1,77 @@
/*
* Copyright (C) 2016 Versity Software, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License v2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/
/*
* This has a crazy name because it's in an external module build at
* the moment. When it's merged upstream it'll move to
* include/trace/events/scoutfs.h
*/
#undef TRACE_SYSTEM
#define TRACE_SYSTEM scoutfs
#if !defined(_TRACE_SCOUTFS_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_SCOUTFS_H
#include <linux/tracepoint.h>
TRACE_EVENT(scoutfs_bloom_hit,
TP_PROTO(struct scoutfs_key *key),
TP_ARGS(key),
TP_STRUCT__entry(
__field(__u64, inode)
__field(__u8, type)
__field(__u64, offset)
),
TP_fast_assign(
__entry->inode = le64_to_cpu(key->inode);
__entry->type = key->type;
__entry->offset = le64_to_cpu(key->offset);
),
TP_printk("key %llu.%u.%llu",
__entry->inode, __entry->type, __entry->offset)
);
TRACE_EVENT(scoutfs_bloom_miss,
TP_PROTO(struct scoutfs_key *key),
TP_ARGS(key),
TP_STRUCT__entry(
__field(__u64, inode)
__field(__u8, type)
__field(__u64, offset)
),
TP_fast_assign(
__entry->inode = le64_to_cpu(key->inode);
__entry->type = key->type;
__entry->offset = le64_to_cpu(key->offset);
),
TP_printk("key %llu.%u.%llu",
__entry->inode, __entry->type, __entry->offset)
);
#endif /* _TRACE_SCOUTFS_H */
/* This part must be outside protection */
/* This part must be outside protection */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#define TRACE_INCLUDE_FILE scoutfs_trace
#include <trace/define_trace.h>

View File

@@ -146,7 +146,7 @@ int scoutfs_read_item(struct super_block *sb, struct scoutfs_key *key,
/* XXX read-ahead all bloom blocks */
ret = scoutfs_test_bloom_bits(sb, le64_to_cpu(ment.blkno),
&bits);
key, &bits);
if (ret < 0)
break;
if (!ret) {