summaryrefslogtreecommitdiffstats
path: root/src/plugins/perfmon
AgeCommit message (Expand)AuthorFilesLines
2019-12-17perfmon: fix per-worker data initializationBenoƮt Ganne2-9/+14
2019-05-24Add callback multiplex supportDave Barach1-15/+47
2019-05-03plugins: clean up plugin descriptionsDave Wallace1-1/+1
2019-05-01Add node, frame to vlib main loop perf analysis callback argumentsDave Barach1-1/+3
2019-03-26perfmon: fix pmc hw indices out-dated when multiple pmcSu Wang1-3/+15
2019-03-20perfmon: python to C parser for intel CPUsDamjan Marion24-445/+23854
2019-01-27Fix issue with cpu_id and numa_code captured too earlyDamjan Marion1-1/+1
2019-01-27perfmon: collect data on selected thread(s)Dave Barach3-18/+86
2019-01-24perfmon: enable pmc event before reading rdpmc indexDamjan Marion1-6/+6
2019-01-24perfmon plugin: 2-way parallel stat collectionDave Barach3-143/+228
2018-12-17Improve perfmon json table pickerDave Barach4-23/+341
2018-11-14Remove c-11 memcpy checks from perf-critical codeDave Barach1-1/+1
2018-10-25Add x86_64 perfmon tablesDave Barach3-20/+10
2018-10-23VPP-1474: fix coverity warningDave Barach1-0/+3
2018-10-23perfmon.c: Register additional cpuids.Paul Vinciguerra1-4/+7
2018-10-22X86_64 perf counter pluginDave Barach5-0/+1466
ght .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (c) 2018 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __THROTTLE_H__
#define __THROTTLE_H__

#include <vlib/vlib.h>
#include <vppinfra/xxhash.h>

/**
 * @brief A throttle
 *  Used in the data plane to decide if a given hash should be throttled,
 *  i.e. that the hash has been seen already 'recently'. Recent is the time
 *  given in the throttle's initialisation.
 */
typedef struct throttle_t_
{
  f64 time;
  uword **bitmaps;
  u64 *seeds;
  f64 *last_seed_change_time;
} throttle_t;

#define THROTTLE_BITS	(512)

extern void throttle_init (throttle_t * t, u32 n_threads, f64 time);

always_inline u64
throttle_seed (throttle_t * t, u32 thread_index, f64 time_now)
{
  if (time_now - t->last_seed_change_time[thread_index] > t->time)
    {
      (void) random_u64 (&t->seeds[thread_index]);
      clib_memset (t->bitmaps[thread_index], 0, THROTTLE_BITS / BITS (u8));

      t->last_seed_change_time[thread_index] = time_now;
    }
  return t->seeds[thread_index];
}

always_inline int
throttle_check (throttle_t * t, u32 thread_index, u64 hash, u64 seed)
{
  int drop;
  uword m;
  u32 w;

  hash = clib_xxhash (hash ^ seed);

  /* Select bit number */
  hash &= THROTTLE_BITS - 1;
  w = hash / BITS (uword);
  m = (uword) 1 << (hash % BITS (uword));

  drop = (t->bitmaps[thread_index][w] & m) != 0;
  t->bitmaps[thread_index][w] |= m;

  return (drop);
}

#endif

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */