mirror of
				https://github.com/ARM-software/devlib.git
				synced 2025-11-03 23:41:21 +00:00 
			
		
		
		
	cgroups: fix get attributes for controller noprefix mounted
CGroups controller can be mounted by specifying a "noprefix" option, in which case attribute names are named as: <mountpoint>/<attribute_name> instead of the (more recent) naming schema using: <mountpoint>/<contoller_name>.<attribute_name> For example, Android uses the old format for backward compatibility with user-space. Thus, it's possible in general to work on a target system where some controller are mounted "noprefix" while others not. This patchset adds a set of updates which allows to use the proper attributes naming schema based on how the controller has been mounted. This patch provides a more generic implementation of the get attributes shutils which is working also for noprefix mounted controllers. Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
This commit is contained in:
		@@ -62,12 +62,26 @@ ftrace_get_function_stats() {
 | 
			
		||||
################################################################################
 | 
			
		||||
 | 
			
		||||
cgroups_get_attributes() {
 | 
			
		||||
	[[ $# -eq 2 ]] || exit -1
 | 
			
		||||
	test $# -eq 2 || exit -1
 | 
			
		||||
	CGROUP="$1"
 | 
			
		||||
	CONTROLLER="$2"
 | 
			
		||||
	$GREP '' $CGROUP/* | \
 | 
			
		||||
		$GREP "$CONTROLLER\." | \
 | 
			
		||||
		$SED -e "s|$CONTROLLER\.||" -e "s|$CGROUP/||"
 | 
			
		||||
	# Check if controller is mounted with "noprefix" option, which is quite
 | 
			
		||||
	# common on Android for backward compatibility
 | 
			
		||||
	ls $CGROUP/$CONTROLLER\.* 2>&1 >/dev/null
 | 
			
		||||
	if [ $? -eq 0 ]; then
 | 
			
		||||
		# no "noprefix" option, attributes format is:
 | 
			
		||||
		#   mnt_point/controller.attribute_name
 | 
			
		||||
		$GREP '' $CGROUP/* | \
 | 
			
		||||
			$GREP "$CONTROLLER\." | \
 | 
			
		||||
			$SED -e "s|$CONTROLLER\.||" -e "s|$CGROUP/||"
 | 
			
		||||
	else
 | 
			
		||||
		# "noprefix" option, attribute format is:
 | 
			
		||||
		#   mnt_point/attribute_name
 | 
			
		||||
		$GREP '' $(\
 | 
			
		||||
			$FIND $CGROUP -type f -maxdepth 1 |
 | 
			
		||||
			$GREP -v -e ".*tasks" -e ".*cgroup\..*") | \
 | 
			
		||||
		$SED "s|$CGROUP/||"
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cgroups_run_into() {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user