Skip to content

Commit 00df7d5

Browse files
Stefan Roeschakpm00
authored andcommitted
mm: add bdi_get_max_bytes() function
This adds a function to return the specified value for max_bytes. It converts the stored max_ratio of the bdi to the corresponding bytes value. It introduces the bdi_get_bytes helper function to do the conversion. This is an approximation as it is based on the value that is returned by global_dirty_limits(), which can change. The helper function will also be used by the min_bytes bdi knob. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Stefan Roesch <[email protected]> Cc: Chris Mason <[email protected]> Cc: Jens Axboe <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent ae82291 commit 00df7d5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

include/linux/backing-dev.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ static inline unsigned long wb_stat_error(void)
105105
/* BDI ratio is expressed as part per 1000000 for finer granularity. */
106106
#define BDI_RATIO_SCALE 10000
107107

108+
u64 bdi_get_max_bytes(struct backing_dev_info *bdi);
108109
int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio);
109110
int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned int max_ratio);
110111
int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit);

mm/page-writeback.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,18 @@ void wb_domain_exit(struct wb_domain *dom)
650650
*/
651651
static unsigned int bdi_min_ratio;
652652

653+
static u64 bdi_get_bytes(unsigned int ratio)
654+
{
655+
unsigned long background_thresh;
656+
unsigned long dirty_thresh;
657+
u64 bytes;
658+
659+
global_dirty_limits(&background_thresh, &dirty_thresh);
660+
bytes = (dirty_thresh * PAGE_SIZE * ratio) / BDI_RATIO_SCALE / 100;
661+
662+
return bytes;
663+
}
664+
653665
int bdi_set_min_ratio(struct backing_dev_info *bdi, unsigned int min_ratio)
654666
{
655667
unsigned int delta;
@@ -701,6 +713,11 @@ int bdi_set_max_ratio(struct backing_dev_info *bdi, unsigned max_ratio)
701713
}
702714
EXPORT_SYMBOL(bdi_set_max_ratio);
703715

716+
u64 bdi_get_max_bytes(struct backing_dev_info *bdi)
717+
{
718+
return bdi_get_bytes(bdi->max_ratio);
719+
}
720+
704721
int bdi_set_strict_limit(struct backing_dev_info *bdi, unsigned int strict_limit)
705722
{
706723
if (strict_limit > 1)

0 commit comments

Comments
 (0)