From 3fd33ece353da336aaab92298929192b78e108b8 Mon Sep 17 00:00:00 2001 From: Daeho Jeong Date: Thu, 23 Jun 2022 16:19:58 -0700 Subject: [PATCH] Make minimum gc sleep time tunnable Test: check smart idle maint log of StorageManagerService Signed-off-by: Daeho Jeong Change-Id: I5a70e4ec2ca895551b6446a9dfd4bb5003a3fbd0 --- IdleMaint.cpp | 7 +++---- IdleMaint.h | 2 +- VoldNativeService.cpp | 5 +++-- VoldNativeService.h | 3 ++- binder/android/os/IVold.aidl | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/IdleMaint.cpp b/IdleMaint.cpp index 426be58..b1565aa 100644 --- a/IdleMaint.cpp +++ b/IdleMaint.cpp @@ -86,7 +86,6 @@ static const int DIRTY_SEGMENTS_THRESHOLD = 100; static const int GC_TIMEOUT_SEC = 420; static const int DEVGC_TIMEOUT_SEC = 120; static const int KBYTES_IN_SEGMENT = 2048; -static const int MIN_GC_URGENT_SLEEP_TIME = 500; static const int ONE_MINUTE_IN_MS = 60000; static const int GC_NORMAL_MODE = 0; static const int GC_URGENT_MID_MODE = 3; @@ -531,7 +530,7 @@ int32_t GetStorageLifeTime() { } void SetGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, float dirtyReclaimRate, - float reclaimWeight, int32_t gcPeriod) { + float reclaimWeight, int32_t gcPeriod, int32_t minGCSleepTime) { std::list paths; bool needGC = true; int32_t sleepTime; @@ -593,8 +592,8 @@ void SetGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, float needGC = false; } else { sleepTime = gcPeriod * ONE_MINUTE_IN_MS / neededSegments; - if (sleepTime < MIN_GC_URGENT_SLEEP_TIME) { - sleepTime = MIN_GC_URGENT_SLEEP_TIME; + if (sleepTime < minGCSleepTime) { + sleepTime = minGCSleepTime; } } } diff --git a/IdleMaint.h b/IdleMaint.h index 9a2af4a..e94f853 100644 --- a/IdleMaint.h +++ b/IdleMaint.h @@ -27,7 +27,7 @@ int RunIdleMaint(bool needGC, const android::sp& int AbortIdleMaint(const android::sp& listener); int32_t GetStorageLifeTime(); void SetGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, float dirtyReclaimRate, - float reclaimWeight, int32_t gcPeriod); + float reclaimWeight, int32_t gcPeriod, int32_t minGCSleepTime); void RefreshLatestWrite(); int32_t GetWriteAmount(); diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp index 51dab49..1284158 100644 --- a/VoldNativeService.cpp +++ b/VoldNativeService.cpp @@ -495,11 +495,12 @@ binder::Status VoldNativeService::getStorageLifeTime(int32_t* _aidl_return) { binder::Status VoldNativeService::setGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, float dirtyReclaimRate, float reclaimWeight, - int32_t gcPeriod) { + int32_t gcPeriod, int32_t minGCSleepTime) { ENFORCE_SYSTEM_OR_ROOT; ACQUIRE_LOCK; - SetGCUrgentPace(neededSegments, minSegmentThreshold, dirtyReclaimRate, reclaimWeight, gcPeriod); + SetGCUrgentPace(neededSegments, minSegmentThreshold, dirtyReclaimRate, reclaimWeight, gcPeriod, + minGCSleepTime); return Ok(); } diff --git a/VoldNativeService.h b/VoldNativeService.h index 4feeada..50ef4e3 100644 --- a/VoldNativeService.h +++ b/VoldNativeService.h @@ -90,7 +90,8 @@ class VoldNativeService : public BinderService, public os::Bn binder::Status abortIdleMaint(const android::sp& listener); binder::Status getStorageLifeTime(int32_t* _aidl_return); binder::Status setGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, - float dirtyReclaimRate, float reclaimWeight, int32_t gcPeriod); + float dirtyReclaimRate, float reclaimWeight, int32_t gcPeriod, + int32_t minGCSleepTime); binder::Status refreshLatestWrite(); binder::Status getWriteAmount(int32_t* _aidl_return); diff --git a/binder/android/os/IVold.aidl b/binder/android/os/IVold.aidl index a946797..8422efb 100644 --- a/binder/android/os/IVold.aidl +++ b/binder/android/os/IVold.aidl @@ -69,7 +69,7 @@ interface IVold { int getStorageLifeTime(); void setGCUrgentPace(int neededSegments, int minSegmentThreshold, float dirtyReclaimRate, float reclaimWeight, - int gcPeriod); + int gcPeriod, int minGCSleepTime); void refreshLatestWrite(); int getWriteAmount();