diff options
author | Jack Diver <diverj@google.com> | 2023-11-16 17:20:59 +0000 |
---|---|---|
committer | Jack Diver <diverj@google.com> | 2024-02-28 18:28:08 +0000 |
commit | 01d962ed80c456fb8b39584fec920621b2832f8a (patch) | |
tree | 2b4916e815dec456be77c4769f95a3e9bf128f9a | |
parent | 0e82736f4877d92e69edd133538ea1ed9ebf76f3 (diff) | |
download | gpu-01d962ed80c456fb8b39584fec920621b2832f8a.tar.gz |
mgm: sysfs node to manually retain SLC partitionandroid-15-beta-1_r0.6android-15-beta-1_r0.4android-15-beta-1_r0.2android-15-beta-1_r0.1android-gs-tangorpro-5.10-android15-dpandroid-gs-pantah-5.10-android15-dpandroid-gs-felix-5.10-android15-dpandroid-gs-bluejay-5.10-android15-dp
Add sysfs node to manually pin the SLC partition in the enabled
state, which is useful when profiling SLC performance.
Bug: 313458962
Test: echo 1 > /sys/kernel/pixel_stat/gpu/mem/slc_pin_partition
Signed-off-by: Jack Diver <diverj@google.com>
(cherry picked from https://partner-android-review.googlesource.com/q/commit:4f276f684312fa600b038553e1ad2b357034dd91)
Merged-In: I5d316d9277c7f514039581f95188f14f86bd87c2
Change-Id: I5d316d9277c7f514039581f95188f14f86bd87c2
-rw-r--r-- | mali_pixel/Documentation/ABI/testing/sysfs-kernel-pixel_stat-gpu | 7 | ||||
-rw-r--r-- | mali_pixel/memory_group_manager.c | 23 | ||||
-rw-r--r-- | mali_pixel/pixel_slc.c | 20 | ||||
-rw-r--r-- | mali_pixel/pixel_slc.h | 5 |
4 files changed, 54 insertions, 1 deletions
diff --git a/mali_pixel/Documentation/ABI/testing/sysfs-kernel-pixel_stat-gpu b/mali_pixel/Documentation/ABI/testing/sysfs-kernel-pixel_stat-gpu new file mode 100644 index 0000000..1d3bc11 --- /dev/null +++ b/mali_pixel/Documentation/ABI/testing/sysfs-kernel-pixel_stat-gpu @@ -0,0 +1,7 @@ +What: /sys/kernel/pixel_stat/gpu/mem/slc_pin_partition +Date: Feb 2024 +Contact: "Jack Diver" <diverj@google.com> +Description: + Write-only node to manually pin the SLC partition in the enabled + state. This useful when profiling SLC performance. + diff --git a/mali_pixel/memory_group_manager.c b/mali_pixel/memory_group_manager.c index 81abfb4..9076a65 100644 --- a/mali_pixel/memory_group_manager.c +++ b/mali_pixel/memory_group_manager.c @@ -254,6 +254,8 @@ extern struct kobject *pixel_stat_gpu_kobj; #define MGM_ATTR_RO(_name) \ static struct kobj_attribute _name##_attr = __ATTR_RO(_name) +#define MGM_ATTR_WO(_name) \ + static struct kobj_attribute _name##_attr = __ATTR_WO(_name) static ssize_t total_page_count_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) @@ -296,10 +298,31 @@ static ssize_t large_page_count_show(struct kobject *kobj, } MGM_ATTR_RO(large_page_count); +static ssize_t slc_pin_partition_store(struct kobject* kobj, + struct kobj_attribute* attr, + const char* buf, + size_t count) +{ + struct mgm_groups *data = container_of(kobj, struct mgm_groups, kobj); + bool pin; + + if (!data) + return -ENODEV; + + if (kstrtobool(buf, &pin)) + return -EINVAL; + + slc_pin(&data->slc_data, pin); + + return count; +} +MGM_ATTR_WO(slc_pin_partition); + static struct attribute *mgm_attrs[] = { &total_page_count_attr.attr, &small_page_count_attr.attr, &large_page_count_attr.attr, + &slc_pin_partition_attr.attr, NULL, }; ATTRIBUTE_GROUPS(mgm); diff --git a/mali_pixel/pixel_slc.c b/mali_pixel/pixel_slc.c index f06d495..45506ab 100644 --- a/mali_pixel/pixel_slc.c +++ b/mali_pixel/pixel_slc.c @@ -56,7 +56,8 @@ static bool partition_required(struct slc_partition *pt) { lockdep_assert_held(&pt->lock); - return atomic_read(&pt->refcount) && (pt->signal >= PARTITION_ENABLE_THRESHOLD); + return (atomic_read(&pt->refcount) && (pt->signal >= PARTITION_ENABLE_THRESHOLD)) || + pt->pinned; } /** @@ -251,6 +252,22 @@ void slc_update_signal(struct slc_data *data, u64 signal) spin_unlock_irqrestore(&pt->lock, flags); } +void slc_pin(struct slc_data *data, bool pin) +{ + struct slc_partition *pt = &data->partition; + unsigned long flags; + + spin_lock_irqsave(&pt->lock, flags); + + pt->pinned = pin; + if (pin) + enable_partition(data, pt); + else if (!partition_required(pt)) + queue_disable_worker(data); + + spin_unlock_irqrestore(&pt->lock, flags); +} + /** * init_partition - Register and initialize a partition with the SLC driver. * @@ -291,6 +308,7 @@ static int init_partition(struct slc_data *data, struct slc_partition *pt, u32 i .enabled = false, .refcount = ATOMIC_INIT(0), .signal = 0, + .pinned = false, }; spin_lock_init(&pt->lock); diff --git a/mali_pixel/pixel_slc.h b/mali_pixel/pixel_slc.h index 1ac3da4..cb8e90d 100644 --- a/mali_pixel/pixel_slc.h +++ b/mali_pixel/pixel_slc.h @@ -54,6 +54,9 @@ struct slc_partition { /** @signal: Partition enable/disable signal from SLC governor */ u64 signal; + + /** @pinned: Is the partition pinned to the enabled state */ + bool pinned; }; /** @@ -88,6 +91,8 @@ void slc_inc_refcount(struct slc_data *data); void slc_dec_refcount(struct slc_data *data); +void slc_pin(struct slc_data *data, bool pin); + void slc_update_signal(struct slc_data *data, u64 signal); #endif /* _PIXEL_SLC_H_ */ |