Blame source/vdo/kernel/histogram.h

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