|
Packit Service |
b3514a |
/*
|
|
Packit Service |
b3514a |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
b3514a |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
b3514a |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
b3514a |
* of the License, or (at your option) any later version.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
b3514a |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
b3514a |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
b3514a |
* GNU General Public License for more details.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
b3514a |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
b3514a |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
b3514a |
* 02110-1301, USA.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/kernel/histogram.h#1 $
|
|
Packit Service |
b3514a |
*/
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#ifndef HISTOGRAM_H
|
|
Packit Service |
b3514a |
#define HISTOGRAM_H
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#include <linux/types.h>
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
typedef struct histogram Histogram;
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Allocate and initialize a histogram that uses linearly sized buckets.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* The histogram label reported via /sys is constructed from several of the
|
|
Packit Service |
b3514a |
* values passed here; it will be something like "Init Label Histogram - number
|
|
Packit Service |
b3514a |
* of countedItems grouped by metric (sampleUnits)", e.g., "Flush Forwarding
|
|
Packit Service |
b3514a |
* Histogram - number of flushes grouped by latency (milliseconds)". Thus
|
|
Packit Service |
b3514a |
* countedItems and sampleUnits should be plural.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* The sampleUnits string will also be reported separately via another /sys
|
|
Packit Service |
b3514a |
* entry to aid in programmatic processing of the results, so the strings used
|
|
Packit Service |
b3514a |
* should be consistent (e.g., always "milliseconds" and not "ms" for
|
|
Packit Service |
b3514a |
* milliseconds).
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param parent The parent kobject.
|
|
Packit Service |
b3514a |
* @param name The short name of the histogram. This label is used
|
|
Packit Service |
b3514a |
* for the sysfs node.
|
|
Packit Service |
b3514a |
* @param initLabel The label for the sampled data. This label is used
|
|
Packit Service |
b3514a |
* when we plot the data.
|
|
Packit Service |
b3514a |
* @param countedItems A name (plural) for the things being counted.
|
|
Packit Service |
b3514a |
* @param metric The measure being used to divide samples into buckets.
|
|
Packit Service |
b3514a |
* @param sampleUnits The unit (plural) for the metric, or NULL if it's a
|
|
Packit Service |
b3514a |
* simple counter.
|
|
Packit Service |
b3514a |
* @param size The number of buckets. There are buckets for every
|
|
Packit Service |
b3514a |
* value from 0 up to size (but not including) size.
|
|
Packit Service |
b3514a |
* There is an extra bucket for larger samples.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return the histogram
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
Histogram *makeLinearHistogram(struct kobject *parent,
|
|
Packit Service |
b3514a |
const char *name,
|
|
Packit Service |
b3514a |
const char *initLabel,
|
|
Packit Service |
b3514a |
const char *countedItems,
|
|
Packit Service |
b3514a |
const char *metric,
|
|
Packit Service |
b3514a |
const char *sampleUnits,
|
|
Packit Service |
b3514a |
int size);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Allocate and initialize a histogram that uses logarithmically sized
|
|
Packit Service |
b3514a |
* buckets.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param parent The parent kobject.
|
|
Packit Service |
b3514a |
* @param name The short name of the histogram. This label is used
|
|
Packit Service |
b3514a |
* for the sysfs node.
|
|
Packit Service |
b3514a |
* @param initLabel The label for the sampled data. This label is used
|
|
Packit Service |
b3514a |
* when we plot the data.
|
|
Packit Service |
b3514a |
* @param countedItems A name (plural) for the things being counted.
|
|
Packit Service |
b3514a |
* @param metric The measure being used to divide samples into buckets.
|
|
Packit Service |
b3514a |
* @param sampleUnits The unit (plural) for the metric, or NULL if it's a
|
|
Packit Service |
b3514a |
* simple counter.
|
|
Packit Service |
b3514a |
* @param logSize The number of buckets. There are buckets for a range
|
|
Packit Service |
b3514a |
* of sizes up to 10^logSize, and an extra bucket for
|
|
Packit Service |
b3514a |
* larger samples.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return the histogram
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
Histogram *makeLogarithmicHistogram(struct kobject *parent,
|
|
Packit Service |
b3514a |
const char *name,
|
|
Packit Service |
b3514a |
const char *initLabel,
|
|
Packit Service |
b3514a |
const char *countedItems,
|
|
Packit Service |
b3514a |
const char *metric,
|
|
Packit Service |
b3514a |
const char *sampleUnits,
|
|
Packit Service |
b3514a |
int logSize);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Allocate and initialize a histogram that uses logarithmically sized
|
|
Packit Service |
b3514a |
* buckets. Values are entered that count in jiffies, and they are
|
|
Packit Service |
b3514a |
* reported in milliseconds.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param parent The parent kobject.
|
|
Packit Service |
b3514a |
* @param name The short name of the histogram. This label is used
|
|
Packit Service |
b3514a |
* for the sysfs node.
|
|
Packit Service |
b3514a |
* @param initLabel The label for the sampled data. This label is used
|
|
Packit Service |
b3514a |
* when we plot the data.
|
|
Packit Service |
b3514a |
* @param countedItems A name (plural) for the things being counted.
|
|
Packit Service |
b3514a |
* @param metric The measure being used to divide samples into buckets.
|
|
Packit Service |
b3514a |
* @param logSize The number of buckets. There are buckets for a range
|
|
Packit Service |
b3514a |
* of sizes up to 10^logSize, and an extra bucket for
|
|
Packit Service |
b3514a |
* larger samples.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @return the histogram
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
Histogram *makeLogarithmicJiffiesHistogram(struct kobject *parent,
|
|
Packit Service |
b3514a |
const char *name,
|
|
Packit Service |
b3514a |
const char *initLabel,
|
|
Packit Service |
b3514a |
const char *countedItems,
|
|
Packit Service |
b3514a |
const char *metric,
|
|
Packit Service |
b3514a |
int logSize);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Enter a sample into a histogram
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param h The histogram
|
|
Packit Service |
b3514a |
* @param sample The sample
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void enterHistogramSample(Histogram *h, uint64_t sample);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**
|
|
Packit Service |
b3514a |
* Free a histogram and null out the reference to it.
|
|
Packit Service |
b3514a |
*
|
|
Packit Service |
b3514a |
* @param hp The reference to the histogram.
|
|
Packit Service |
b3514a |
**/
|
|
Packit Service |
b3514a |
void freeHistogram(Histogram **hp);
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#endif /* HISTOGRAM_H */
|