X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fcoverage.c;h=0deb5265a4a3e8e6bd480bdbff413bc5feeec7e6;hb=c23740be661db40a54b8cd0c397945fb3987e771;hp=2b8b6e6ced1edb32077cc55fade1691bcf62307a;hpb=d76f09ea77e03ee5a3a7bb67bcab1ac4bb54172b;p=sliver-openvswitch.git diff --git a/lib/coverage.c b/lib/coverage.c index 2b8b6e6ce..0deb5265a 100644 --- a/lib/coverage.c +++ b/lib/coverage.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010 Nicira Networks. + * Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ #include #include "dynamic-string.h" #include "hash.h" +#include "timeval.h" #include "unixctl.h" #include "util.h" #include "vlog.h" @@ -48,17 +49,18 @@ struct coverage_counter *coverage_counters[] = { static unsigned int epoch; static void -coverage_unixctl_log(struct unixctl_conn *conn, const char *args OVS_UNUSED, - void *aux OVS_UNUSED) +coverage_unixctl_log(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *aux OVS_UNUSED) { coverage_log(VLL_WARN, false); - unixctl_command_reply(conn, 200, NULL); + unixctl_command_reply(conn, NULL); } void coverage_init(void) { - unixctl_command_register("coverage/log", coverage_unixctl_log, NULL); + unixctl_command_register("coverage/log", "", 0, 0, + coverage_unixctl_log, NULL); } /* Sorts coverage counters in descending order by count, within equal counts @@ -122,12 +124,20 @@ coverage_hit(uint32_t hash) static uint32_t hit[HIT_BITS / BITS_PER_WORD]; BUILD_ASSERT_DECL(IS_POW2(HIT_BITS)); + static long long int next_clear = LLONG_MIN; + unsigned int bit_index = hash & (HIT_BITS - 1); unsigned int word_index = bit_index / BITS_PER_WORD; unsigned int word_mask = 1u << (bit_index % BITS_PER_WORD); + /* Expire coverage hash suppression once a day. */ + if (time_msec() >= next_clear) { + memset(hit, 0, sizeof hit); + next_clear = time_msec() + 60 * 60 * 24 * 1000LL; + } + if (hit[word_index] & word_mask) { - return true; + return true; } else { hit[word_index] |= word_mask; return false;