mirror of
https://github.com/schoebel/mars
synced 2025-04-09 11:01:38 +00:00
import mars-96.tgz
This commit is contained in:
parent
cc38199823
commit
4e77bbc1c3
45
brick.c
45
brick.c
@ -16,6 +16,51 @@
|
||||
|
||||
#define GFP_BRICK GFP_NOIO
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
// messaging
|
||||
|
||||
#ifdef CONFIG_DEBUG_KERNEL
|
||||
|
||||
#include <linux/preempt.h>
|
||||
#include <linux/hardirq.h>
|
||||
|
||||
static char say_buf[1024] = {};
|
||||
static int say_index = 0;
|
||||
|
||||
void say_mark(void)
|
||||
{
|
||||
if (say_buf[0]) {
|
||||
printk("# %s", say_buf);
|
||||
say_buf[0] = '\0';
|
||||
say_index = 0;
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(say_mark);
|
||||
|
||||
void say(const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
if (preempt_count() & (PREEMPT_MASK | SOFTIRQ_MASK | HARDIRQ_MASK)) {
|
||||
va_start(args, fmt);
|
||||
say_index += vsnprintf(say_buf + say_index, sizeof(say_buf) - say_index, fmt, args);
|
||||
va_end(args);
|
||||
if (unlikely(say_index >= sizeof(say_buf))) {
|
||||
say_index = sizeof(say_buf);
|
||||
say_buf[say_index-1] = '\0';
|
||||
}
|
||||
} else {
|
||||
say_mark();
|
||||
va_start(args, fmt);
|
||||
vprintk(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL(say);
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// number management
|
||||
|
18
brick.h
18
brick.h
@ -7,12 +7,21 @@
|
||||
#include <linux/sched.h>
|
||||
#include <linux/wait.h>
|
||||
|
||||
#include <asm/atomic.h>
|
||||
|
||||
#ifdef CONFIG_DEBUG_KERNEL
|
||||
#define INLINE inline
|
||||
//#define INLINE __attribute__((__noinline__))
|
||||
#else
|
||||
extern void say(const char *fmt, ...);
|
||||
extern void say_mark(void);
|
||||
|
||||
#else // CONFIG_DEBUG_KERNEL
|
||||
|
||||
#define INLINE inline
|
||||
#endif
|
||||
#define say printk
|
||||
#define say_mark() /*empty*/
|
||||
|
||||
#endif // CONFIG_DEBUG_KERNEL
|
||||
|
||||
#ifdef _STRATEGY
|
||||
#define _STRATEGY_CODE(X) X
|
||||
@ -30,7 +39,7 @@
|
||||
|
||||
#define _BRICK_FMT(fmt) __BASE_FILE__ " %d %s(): " fmt, __LINE__, __FUNCTION__
|
||||
|
||||
#define _BRICK_MSG(PREFIX, fmt, args...) do { printk(PREFIX _BRICK_FMT(fmt), ##args); } while (0)
|
||||
#define _BRICK_MSG(PREFIX, fmt, args...) do { say(PREFIX _BRICK_FMT(fmt), ##args); } while (0)
|
||||
|
||||
#define BRICK_FAT(fmt, args...) _BRICK_MSG(BRICK_FATAL, fmt, ##args)
|
||||
#define BRICK_ERR(fmt, args...) _BRICK_MSG(BRICK_ERROR, fmt, ##args)
|
||||
@ -709,6 +718,7 @@ extern void set_lamport(struct timespec *old);
|
||||
do { \
|
||||
spin_unlock_irqrestore(spinlock, flags); \
|
||||
atomic_dec(¤t->lock_count); \
|
||||
say_mark(); \
|
||||
} while (0)
|
||||
|
||||
# define traced_readlock(spinlock,flags) \
|
||||
@ -726,6 +736,7 @@ extern void set_lamport(struct timespec *old);
|
||||
/*spin_unlock_irqrestore(spinlock,flags);*/ \
|
||||
read_unlock(spinlock); \
|
||||
atomic_dec(¤t->lock_count); \
|
||||
say_mark(); \
|
||||
} while (0)
|
||||
|
||||
# define traced_writelock(spinlock,flags) \
|
||||
@ -743,6 +754,7 @@ extern void set_lamport(struct timespec *old);
|
||||
/*spin_unlock_irqrestore(spinlock,flags);*/ \
|
||||
write_unlock(spinlock); \
|
||||
atomic_dec(¤t->lock_count); \
|
||||
say_mark(); \
|
||||
} while (0)
|
||||
|
||||
#else
|
||||
|
5
mars.h
5
mars.h
@ -2,10 +2,7 @@
|
||||
#ifndef MARS_H
|
||||
#define MARS_H
|
||||
|
||||
#include <linux/list.h>
|
||||
#include <linux/semaphore.h>
|
||||
#include <asm/spinlock.h>
|
||||
#include <asm/atomic.h>
|
||||
|
||||
#define MEMLEAK // FIXME: remove this
|
||||
//#define MARS_TRACING // write runtime trace data to /mars/trace.csv
|
||||
@ -42,7 +39,7 @@
|
||||
#define _MARS_FMT(fmt) "[%s] " __BASE_FILE__ " %d %s(): " fmt, current->comm, __LINE__, __FUNCTION__
|
||||
//#define _MARS_FMT(fmt) _BRICK_FMT(fmt)
|
||||
|
||||
#define _MARS_MSG(PREFIX, fmt, args...) do { printk(PREFIX _MARS_FMT(fmt), ##args); MARS_DELAY; } while (0)
|
||||
#define _MARS_MSG(PREFIX, fmt, args...) do { say(PREFIX _MARS_FMT(fmt), ##args); MARS_DELAY; } while (0)
|
||||
#define MARS_FAT(fmt, args...) _MARS_MSG(MARS_FATAL, fmt, ##args)
|
||||
#define MARS_ERR(fmt, args...) _MARS_MSG(MARS_ERROR, fmt, ##args)
|
||||
#define MARS_WRN(fmt, args...) _MARS_MSG(MARS_WARNING, fmt, ##args)
|
||||
|
@ -145,6 +145,8 @@ void q_insert(struct logger_queue *q, struct trans_logger_mref_aspect *mref_a)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
CHECK_ATOMIC(&mref_a->object->ref_count, 1);
|
||||
|
||||
mars_trace(mref_a->object, q->q_insert_info);
|
||||
|
||||
traced_lock(&q->q_lock, flags);
|
||||
@ -170,6 +172,8 @@ void q_pushback(struct logger_queue *q, struct trans_logger_mref_aspect *mref_a)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
||||
CHECK_ATOMIC(&mref_a->object->ref_count, 1);
|
||||
|
||||
mars_trace(mref_a->object, q->q_pushback_info);
|
||||
|
||||
if (q->q_ordering) {
|
||||
@ -231,6 +235,7 @@ struct trans_logger_mref_aspect *q_fetch(struct logger_queue *q)
|
||||
traced_unlock(&q->q_lock, flags);
|
||||
|
||||
if (mref_a) {
|
||||
CHECK_ATOMIC(&mref_a->object->ref_count, 1);
|
||||
mars_trace(mref_a->object, q->q_fetch_info);
|
||||
}
|
||||
|
||||
@ -340,6 +345,7 @@ void hash_insert(struct trans_logger_output *output, struct trans_logger_mref_as
|
||||
|
||||
#if 1
|
||||
CHECK_HEAD_EMPTY(&elem_a->hash_head);
|
||||
CHECK_ATOMIC(&elem_a->object->ref_count, 1);
|
||||
#endif
|
||||
|
||||
// only for statistics:
|
||||
@ -384,6 +390,8 @@ void hash_extend(struct trans_logger_output *output, loff_t *_pos, int *_len, st
|
||||
test_a = container_of(tmp, struct trans_logger_mref_aspect, hash_head);
|
||||
test = test_a->object;
|
||||
|
||||
CHECK_ATOMIC(&test->ref_count, 1);
|
||||
|
||||
// are the regions overlapping?
|
||||
if (test_a->is_collected || pos >= test->ref_pos + test->ref_len || pos + len <= test->ref_pos) {
|
||||
continue; // not relevant
|
||||
@ -450,6 +458,9 @@ void hash_put_all(struct trans_logger_output *output, struct list_head *list)
|
||||
|
||||
elem_a = container_of(tmp, struct trans_logger_mref_aspect, collect_head);
|
||||
elem = elem_a->object;
|
||||
|
||||
CHECK_ATOMIC(&elem->ref_count, 1);
|
||||
|
||||
hash = hash_fn(elem->ref_pos);
|
||||
if (!start) {
|
||||
first_hash = hash;
|
||||
@ -692,7 +703,6 @@ restart:
|
||||
// are we a shadow (whether master or slave)?
|
||||
shadow_a = mref_a->shadow_ref;
|
||||
if (shadow_a) {
|
||||
unsigned long flags;
|
||||
bool finished;
|
||||
|
||||
CHECK_ATOMIC(&mref->ref_count, 1);
|
||||
@ -706,19 +716,15 @@ restart:
|
||||
if (!finished) {
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK_HEAD_EMPTY(&mref_a->hash_head);
|
||||
CHECK_HEAD_EMPTY(&mref_a->q_head);
|
||||
CHECK_HEAD_EMPTY(&mref_a->replay_head);
|
||||
CHECK_HEAD_EMPTY(&mref_a->collect_head);
|
||||
CHECK_HEAD_EMPTY(&mref_a->sub_list);
|
||||
CHECK_HEAD_EMPTY(&mref_a->sub_head);
|
||||
#ifdef WEG // FIXME: do bookkeping here
|
||||
traced_lock(&output->brick->pos_lock, flags);
|
||||
list_del_init(&mref_a->pos_head);
|
||||
traced_unlock(&output->brick->pos_lock, flags);
|
||||
#else
|
||||
CHECK_HEAD_EMPTY(&mref_a->pos_head);
|
||||
#endif
|
||||
|
||||
if (shadow_a != mref_a) { // we are a slave shadow
|
||||
//MARS_DBG("slave\n");
|
||||
atomic_dec(&output->sshadow_count);
|
||||
@ -871,6 +877,28 @@ err:
|
||||
|
||||
////////////////////////////// writeback info //////////////////////////////
|
||||
|
||||
static noinline
|
||||
void pos_complete(struct trans_logger_mref_aspect *orig_mref_a)
|
||||
{
|
||||
struct trans_logger_output *output = orig_mref_a->output;
|
||||
struct trans_logger_brick *brick = output->brick;
|
||||
struct list_head *tmp;
|
||||
unsigned long flags;
|
||||
|
||||
// save final completion status
|
||||
traced_lock(&brick->pos_lock, flags);
|
||||
tmp = &orig_mref_a->pos_head;
|
||||
if (tmp == brick->pos_list.next) {
|
||||
loff_t finished = orig_mref_a->log_pos;
|
||||
if (finished <= brick->replay_pos) {
|
||||
MARS_ERR("backskip in log replay: %lld -> %lld\n", brick->replay_pos, orig_mref_a->log_pos);
|
||||
}
|
||||
brick->replay_pos = finished;
|
||||
}
|
||||
list_del_init(tmp);
|
||||
traced_unlock(&brick->pos_lock, flags);
|
||||
}
|
||||
|
||||
static noinline
|
||||
void free_writeback(struct writeback_info *wb)
|
||||
{
|
||||
@ -886,6 +914,9 @@ void free_writeback(struct writeback_info *wb)
|
||||
orig_mref = orig_mref_a->object;
|
||||
|
||||
CHECK_ATOMIC(&orig_mref->ref_count, 1);
|
||||
|
||||
pos_complete(orig_mref_a);
|
||||
|
||||
#ifdef CLEAN_ALL
|
||||
__trans_logger_ref_put(orig_mref_a->output, orig_mref_a);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user