Dongwoo Lee [Mon, 4 Jul 2022 06:19:07 +0000 (15:19 +0900)]
resource: process: Add checking support for PROCESS_ATTR_GPU_MEM
Change-Id: Icc7f49ee785f668f8e6afc68c6960a4d4c81c438
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 4 Jul 2022 02:41:38 +0000 (11:41 +0900)]
resource: process-group: Add checking support for PROCESS_GROUP_ATTR_GPU_MEM
Change-Id: Iefbaa9526f62fe1af5fb054f8cbacbe81863bb9b
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 4 Jul 2022 02:14:38 +0000 (11:14 +0900)]
util: kernel: gpu-mem: Improve process for finding gpu node
To get rid of redundant gpu node checking at every update, finding gpu
node will be proceeded at once as constructor.
Change-Id: I30c18784f578e224e812c9ee9e0d9a4704cf901a
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Fri, 1 Jul 2022 05:39:58 +0000 (14:39 +0900)]
util: kernel: gpu-mem: Fix missing header file
Change-Id: Iec6278b4a5cab50315b3f42f28cc12205d5d2ee7
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Chanwoo Choi [Mon, 4 Jul 2022 18:53:39 +0000 (03:53 +0900)]
util: kernel: Remove unused variable to fix build warning
Fix the following warning.
/home/abuild/rpmbuild/BUILD/pass-1.2.0/src/util/kernel.c:
In function 'get_gpu_mem_info':
/home/abuild/rpmbuild/BUILD/pass-1.2.0/src/util/kernel.c:435:6:
warning: variable 'n' set but not used [-Wunused-but-set-variable]
| int n;
Change-Id: Ie763f9bf4f2aa61aa22535ca0209871359306419
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Tue, 5 Jul 2022 10:11:15 +0000 (19:11 +0900)]
pass: parser: Replace with bool data type to prevent mismatched type casting
Until now, even if use DATA_TYPE_BOOLEN, use 'int' variable type.
It might cause the unknown issue by mismatched type casting
on get_property() fucntion. In order to prevent the wrong type casting,
replace with bool data type instead of integer type.
Change-Id: I51791d72579afc97b73b6a67d9a9711c21c033f4
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Mon, 4 Jul 2022 03:32:06 +0000 (12:32 +0900)]
util: common: Replace prototype of json helper functions to get correct value
The get_int_from_object() returns '-EINVAL' when json object doesn't
contain ' key'. But it isn't correct because 'int' value is able
to get the minus value. It means that when get_int_from_object() return -EINVAL,
it is not error on side of user. To fix them, return the error and then
get the value as the parameter. Also, get_double_from_object() has the same issue.
Also, in order that keep the consistent prototype of json helper functions,
changes the functiosn as following:
- int get_int_from_object(json_object *obj, const char *key, int *data);
- int get_double_from_object(json_object *obj, const char *key, double *data);
- int get_boolean_from_object(json_object *obj, const char *key, bool *data);
Change-Id: I0a9b9da36312a0d86920f259b1f702095f104da6
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Sun, 3 Jul 2022 17:20:04 +0000 (02:20 +0900)]
pmqos: parser: Distinguish mandatory property or optional with get_property
Change-Id: Ifef64ee85c00f4c7a2b695aa5edf80ac6e42c824
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Sun, 3 Jul 2022 17:17:18 +0000 (02:17 +0900)]
thermal: parser: Distinguish mandatory property or optional with get_property
Change-Id: I301aefac2dd006b6ba4406b0e813947c949aa490
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Fri, 24 Jun 2022 07:35:30 +0000 (16:35 +0900)]
pass: parser: Distinguish mandatory property or optional with get_property
Actually, it is difficult and complicated to specify
whether some property is mandatory or optional even if
it is requied.
Specify either mandatory or optional status of each property
with get_property() function. If some property is mandatory,
just pass the true into 3rd argument of get_property.
In case of mandatory property, get_property returns error
if property is absent. On the other hand, get_property
returns non-zero with debug level log about absent property.
And also, should print the error for non-existent mandatory properteis
in same section at the same time. It helps user to fix
the configuration.
For example,
- 'device_type' and 'device_name' properties are mandatory
and 'thermal_device_name' property is optional property.
ret += get_property(obj, "device_type", DATA_TYPE_STRING,
true, (void *)device_type);
ret += get_property(obj, "device_name", DATA_TYPE_STRING,
true, (void *)device_name);
ret += get_property(obj, "thermal_device_name", DATA_TYPE_STRING,
false, (void *)thermal_device_name);
if (ret < 0) {
_E("Failed to get mandatory properties in device_list\n");
return ret;
}
- result of error log
Failed to get property of 'device_type' (log for mandatory property)
Failed to get property of 'device_name' (log for mandatory property)
There is no property of 'thermal_priority' (log for optional property)
Failed to get mandatory properties in device_list
cannot parse of 0th resource in 'device_list' section
Change-Id: I2e8a87788eadb7550369378af4adfec0774bdc8a
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Fri, 24 Jun 2022 06:13:09 +0000 (15:13 +0900)]
util: common: Add get_property to simplify the property getting operation
There are already helper funciton to get value from json object.
In order to simpilfy the code getting value from json object,
add get_value_from_object function with data type arguemnt.
[Detailed description of get_property]
int get_property(json_object *obj, const char *key,
int type, bool mandatory, void *data)
- json_object *obj : json object
- const char *key : property key
- int type : data type of property
- bool mandatory : if property is mandatory, true.
- void *data : each data will be stored
Change-Id: Ifd217ae5773e11ccb1f2d74850ee1c68fb035ebe
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Fri, 24 Jun 2022 05:29:56 +0000 (14:29 +0900)]
util: common: Move enum data_type into common.h and rename it
The previous enum monitor_data_type will be used for all data.
So that move enum monitor_data_type into common.h
and then rename from enum monitor_data_type to enum data_type
with more generic enumeration name. And add new DATA_TYPE_BOOLEAN
for boolean type.
Change-Id: I38c459057fb4962af883fc5a043f0a4f1ffda8f2
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Wed, 22 Jun 2022 10:05:44 +0000 (19:05 +0900)]
tests: unittest: Add pass-parser test for each resource
Add the unittest of pass-parser features which parse the each resource
configurations.
Change-Id: I1eaacd4340d4d19d236285a98ef0c10772ca9a46
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Thu, 23 Jun 2022 08:31:29 +0000 (17:31 +0900)]
tests: unittest: Add unittest of pass-parser module
PASS daemon requires the json configuration containing
the device-dependent information. The described information
of json configuration are used for PASS opeartion.
Add unittest of pass-parser module for both valid
and invalid case under 'device_list' property.
Change-Id: I63b650dc34ddefe9873f28e0a9c46fff21e90936
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Sun, 3 Jul 2022 14:48:41 +0000 (23:48 +0900)]
pass: parser: Use const keyword for configuration file path
In order to remove the chagnes of the file path of configuration
by internal logic of pass-parser module, use const keyword for them
as following:
- int pass_parser_get_resource_config(struct pass *pass, const char *path)
- int pass_parser_get_each_resource_config(struct pass_resource *res, const char *path)
Change-Id: Ie5440b9c86b26515db2236362e3518743769f565
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Tue, 21 Jun 2022 18:37:49 +0000 (03:37 +0900)]
pass: parser: Change board name checking to be an optional
The board name checking was mandatory before.
But, the new requirement which supports the PASS daemon
without HAL configuration is requested.
Change board name checking to be an optional.
Change-Id: I64ff9296abc6537057b85a29e9984eefe4e9996a
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Sun, 3 Jul 2022 14:54:29 +0000 (23:54 +0900)]
util: kernel: Fix build warning of what const keyword is missing
Fix the following build warning:
[ 14s] /home/abuild/rpmbuild/BUILD/pass-1.2.0/src/resource/resource-process.c:347:53:
warning: passing argument 1 of 'is_resource_attr_interested' discards 'const' qualifier
from pointer target type [-Wdiscarded-qualifiers]
[ 14s] 347 | bool include_gpu_mem = is_resource_attr_interested(res, PROCESS_GROUP_ATTR_MEM_GPU);
Change-Id: I5a39513e20158c02343eb7c1d644f80ea0cba973
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Dongwoo Lee [Tue, 21 Jun 2022 12:38:24 +0000 (21:38 +0900)]
resource: process: Add PROCESS_ATTR_MEM_GPU attribute
Change-Id: Ie614d613cd242dd8dfaf4d315a0e122e88a9ae43
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 20 Jun 2022 11:16:27 +0000 (20:16 +0900)]
resource: process-group: Add PROCESS_GROUP_ATTR_MEM_GPU attribute
Change-Id: If047337cb4efd57ae19fcfbf3a89be95542b7e84
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Chanwoo Choi [Wed, 29 Jun 2022 01:44:08 +0000 (10:44 +0900)]
util: resource: Add new is_resource_attr_interested function
Provide is_resource_attr_interested function to check whether
some attribute id is already interested or not. It will be
used as internal function for libpass-resource-monitor
and capi-resource-monitor.
Change-Id: I1cdac2eab2672869cfa98069fc7d958c4da4dc93
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Dongwoo Lee [Mon, 20 Jun 2022 11:16:27 +0000 (20:16 +0900)]
util: kernel: Make getting further information from smaps files
Now, kernel_get_thread_group_map_info() function can get gpu memory
information by retrieving section has the name of gpu device.
If the gpu memory information is not required, using smaps rather
harms performance, callee must specified whether gpu memory is
required, unless smaps_rollup is used if it is supported.
Change-Id: Ibe17aea337645ca6312df9472c252d962f158762
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 16 Jun 2022 04:52:37 +0000 (13:52 +0900)]
resource: process: Add additional memory attributes
This adds new memory attributes:
- PROCESS_ATTR_MEM_PSS
- PROCESS_ATTR_MEM_SWAP
- PROCESS_ATTR_MEM_SWAP_PSS
Change-Id: Ie21ca0aedf9cb1175c2d49d89e7e0487e7460abc
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 16 Jun 2022 02:21:41 +0000 (11:21 +0900)]
resource: process: Consolidate memory attribute functions
To reduce the redundant code and make easy to add the new memory
attribute, this make use consolidate functions for memory attributes.
Change-Id: I551b8cf9dac43ae972ad9007c1c2791ed985367f
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 12 May 2022 05:45:29 +0000 (14:45 +0900)]
resource: process-group: Add additional memory attributes
This adds new memory attributes:
- PROCESS_GROUP_ATTR_MEM_PSS
- PROCESS_GROUP_ATTR_MEM_SWAP
- PROCESS_GROUP_ATTR_MEM_SWAP_PSS
Change-Id: I78062afa487d186489e4b9a7eea479f7b5f1be72
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 16 Jun 2022 07:40:34 +0000 (16:40 +0900)]
pass: Add capability for procfs access
Change-Id: I72c186afad13f4a21400ea96f09ad72e3a42a8a1
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Chanwoo Choi [Tue, 21 Jun 2022 03:05:45 +0000 (12:05 +0900)]
pass: hal: Add missing parameter validation
If enter the wrong value, it cause the fault and wrong operation.
So that add the missing parameter validation checking
to prevent the wrong operation. Add missing parameter validation
by using the unittest result of pass-hal module.
- Detailed the unittest result of pass-hal module
[ FAILED ] PassHalTest.pass_hal_set_online_state (7 ms)
[ FAILED ] PassHalTest.pass_hal_set_cooling_device_state (1 ms)
[ FAILED ] PassHalTest.pass_hal_set_battery_charging_status (1 ms)
[ FAILED ] PassHalTest.pass_hal_set_battery_charging_current (1 ms)
[ FAILED ] PassHalTest.pass_hal_set_fault_around_bytes (1 ms)
Change-Id: Id320b77188508d82bc68137c65bb5b7d81729c55
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Mon, 20 Jun 2022 08:10:48 +0000 (17:10 +0900)]
tests: unittest: Add unittest of pass-hal module
The pass-hal module is in charge of communicating with hal-api-power
for writing the value to h/w resource such as CPU/GPU/Battery etc
and for reading the value from h/w resources.
Change-Id: Icc9b5d48b2a30771753afd241e39e67ddf86c62f
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Mon, 20 Jun 2022 08:10:30 +0000 (17:10 +0900)]
tests: unittest: Add hal-api-power mock class
PASS comunicates with hal-api-power to read/write the h/w resources
such as CPU/Memory Bus/GPU/Memroy and so on. For the testing on build
time, it requires the mocking of hal-api-power. In result, add hal-api-power
mock class.
Change-Id: I75e7537d3a94059d586943810c502882d24a1517
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Mon, 20 Jun 2022 04:38:01 +0000 (13:38 +0900)]
tests: unittest: Add pass-unittest skeleton for testing pass module
PASS daemon contains the modules such as pass-parser, pass-hal,
pass-rescon, pass-resmon and son on. It requires the testing
on building time. In order to support the unittest of pass module,
add pass-unittest skeleton code.
Change-Id: Ie4c8637b4c0b5045b59eb3a92495f132aeb0c6e3
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Fri, 17 Jun 2022 09:03:11 +0000 (18:03 +0900)]
tests: Move test code into tests directory and redefine the test role
Move test code into tests directory and redefine the test role as
following because unittest will be added for each module.
- intergraion test : Test the public interface of PASS daemon
- haltest : Test the HAL interface of PASS daemon
Change-Id: Ief0d07b38491454dc0dbb06a268e5c56de31a886
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Dongwoo Lee [Thu, 12 May 2022 05:44:33 +0000 (14:44 +0900)]
util: kernel: Add functions for getting process smaps file
Change-Id: Id8b9d677585ccc4381c33eb53373037c64540f59
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Seung-Woo Kim [Fri, 17 Jun 2022 06:15:15 +0000 (15:15 +0900)]
pass: Remove unnecessary installed service files
The dbus activation service files are not necessary in systemd
unitdir. Remove unnecessary installation of dbus activation
service files.
This removes below packaging warning message:
warning: Installed (but unpackaged) file(s) found:
/usr/lib/systemd/system/org.tizen.system.pass.service
/usr/lib/systemd/system/org.tizen.system.thermal.service
Change-Id: I5c13e31032b07db7ac11271ad5f231737383b0f8
Fixes: commit
d0b00031fc66 ("core: Add support for dbus activation for thermal")
Fixes: commit
da1dc2ab2a66 ("core: Apply systemd-based dbus activation")
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Seung-Woo Kim [Fri, 17 Jun 2022 06:04:56 +0000 (15:04 +0900)]
packaging: Remove unnecessary symlink in sockets.target.wants
After removing pass.socket, symlink to it in sockets.target.wants
remains. Remove unnecessary symlink.
This removes next packaging warning message:
warning: Installed (but unpackaged) file(s) found:
/usr/lib/systemd/system/sockets.target.wants/pass.socket
Change-Id: I8f02dc5d83d8ecd41cf4c3e440b8eeb917bb0aee
Fixes: commit
00a3aedc ("pass: Remove unused pass.socket file")
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Sung-hun Kim [Mon, 30 May 2022 06:59:21 +0000 (15:59 +0900)]
resource: memory: Add MEMORY_ATTR_SWAP_TOTAL and MEMORY_ATTR_SWAP_FREE attributes
Change-Id: I8f6e3ff274c429fe2e5d2f9378ea4e8ae18dccaf
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
Dongwoo Lee [Thu, 12 May 2022 07:09:32 +0000 (16:09 +0900)]
util: timer: Fix possible dangling pointer and memory leak
Change-Id: I466617b365e91108c0ed3cdf1d95c8a237feaad8
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Fri, 8 Apr 2022 07:59:30 +0000 (16:59 +0900)]
monitor: resource: Add function for getting resource and its attributes list
To provide way to manage monitoring module without static list, now
json type information for resource and its attributes list can be
retrieved with following function:
- pass_resource_monitor_get_resource_list_json()
Change-Id: Ib9c8787a081f674fc1d6bdf12d9d027cca4b0352
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Fri, 8 Apr 2022 03:04:08 +0000 (12:04 +0900)]
monitor: resource: Add timestamp support
To provide timeline information of resource update, now provides
timestamp as start and end time of update. It is included in resource
json as "res_ts" with "start" and "end" object, and it also can be
retrieved with following new libpass function:
- pass_resource_monitor_get_resource_timestamp()
Change-Id: Iad2cf8bb1d1100f4ded44ce5e19aeb119c65575e
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 11 Apr 2022 11:28:37 +0000 (20:28 +0900)]
resource: process-group: Fix unnecessary assignment and meaningless code
Change-Id: I600fc27afa7ecb95853bc492bd997ee8d99d1e9a
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Sun, 3 Apr 2022 14:14:22 +0000 (23:14 +0900)]
resource: process-group: Add aggregated attributes for accounting stats
To provide aggregated accounting information about the process group
which includes target process and its child at a driver level, the
structure managing the current process group is changed from list to
hash, and it is preserved until root target is changed or a prcess in
a group is terminated to maintain previous stats. Thus, the clients can
retrieved aggregated accounting stats without create the individual
process driver. Newly added attributes are as follows:
- PROCESS_GROUP_ATTR_CPU_UTIL
- PROCESS_GROUP_ATTR_DISK_READ_BPS
- PROCESS_GROUP_ATTR_DISK_WRITE_BPS
- PROCESS_GROUP_ATTR_MEM_VIRT
- PROCESS_GROUP_ATTR_MEM_RSS
Change-Id: I967da6110fb8568383c2ba096d599f51ce8e54e2
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 31 Mar 2022 04:32:25 +0000 (13:32 +0900)]
resource: process-group: Use taskstats instead of reading procfs
To lower the overhead of getting information about process, use
taskstats instead of reading procfs while building group list.
Moreover, two advantages can be gained as using taskstats directly:
1. Lower number of copy
2. Using taskstats accounting information without process driver
Change-Id: I5242d25ab864b05674d9af01838d3401a356a1df
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 31 Mar 2022 04:16:49 +0000 (13:16 +0900)]
resource: process: Get initial stats of target process with taskstats
Since open and read procfs task stat often cause performance
degradation in the case that many process drivers are frequentyl
set control. To reduce this overhead, now initial stats are retrieved
by taskstats and 'pgid' which cannot be retrieved by taskstats is
get lazily once at the first reading.
Change-Id: I9bae9965a17192fbc0ab5789df45a782ab97ca9d
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 31 Mar 2022 03:14:56 +0000 (12:14 +0900)]
util: kernel: Make query_taskstats() common kernel utility function
To use taskstats in other drivers as well as process driver,
query_taskstat() now become common kernel utility function and
name is changed as following kernel util naming rules.
Change-Id: I64eff1892d908d22a0f8f831949b2c072cc0e68b
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Chanwoo Choi [Fri, 1 Apr 2022 05:34:13 +0000 (14:34 +0900)]
lib: resource-monitor: Rename to libpass-resource-monitor from tmonitor
Change-Id: If008aa6ab64b04226f97709ea48e13e459cc9a61
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Dongwoo Lee [Tue, 29 Mar 2022 02:41:54 +0000 (11:41 +0900)]
util: resource: Add JSON format support
To extend use of monitor resource, now all attributes in resource can
be retrieved as JSON type format at once with new api below:
- tmonitor_get_value_json: get a attribute of resource as json format
- tmonitor_get_resource_json: get all attributes of resource as json
format
Change-Id: I14b1f5e2474d101ff7149a3377b2ebc1890223c8
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Tue, 29 Mar 2022 05:24:47 +0000 (14:24 +0900)]
monitor: Change delimiter for request/response tokenizing
Since JSON format use character ':' as its internal representation,
delimiter of API tokenizing is change into '$'.
Change-Id: I0705eeb4a860cd279e9ee7b1ab62db3318786fc6
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 28 Mar 2022 11:47:14 +0000 (20:47 +0900)]
util: resource: Unset attrs when resource is deleted
To free memory allocated to data_value arrays of resource, unset attr
function is invoked while deleting resource.
Change-Id: Id5c87a7a5afb64c4bd94da1894ad8fca7ec1b272
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Chanwoo Choi [Wed, 30 Mar 2022 05:07:04 +0000 (14:07 +0900)]
lib: libpass: Rename to libpass.pc and add libpass.co to libpass-devel pkg
Rename the pkgconfig file name from pass.pc to libpass.pc
and add libpass.so to libpass-devel package
Change-Id: I45fcb5546a72586c263d2727a30040545d96820c
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Tue, 29 Mar 2022 08:51:38 +0000 (17:51 +0900)]
lib: tmonitor: Add missing detailed value type if DATA_TYPE_ARRAY
Change-Id: I80882c06b2b91dfdc321a609de6af97a3bfc4b54
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Dongwoo Lee [Fri, 25 Mar 2022 02:08:33 +0000 (11:08 +0900)]
util: request: Use different size of buffer along with request type
To exchange large size of array, size of response for array request
should be distingushed by others. So, instead of static buffer, nowa
buffer of response is dynamically allocated along with request type.
Change-Id: I845fe444c3736ee2fef8ea99482ede6d48262b3f
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Wed, 23 Mar 2022 10:34:03 +0000 (19:34 +0900)]
resource: process-group: Add PROCESS_GROUP_ATTR_COMM_LIST attribute
Change-Id: I977281252290f1d92d028db3a38390f5feac0848
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Wed, 23 Mar 2022 10:27:02 +0000 (19:27 +0900)]
resource: process-group: Change update attributes method
Instead of get process group list at individual callback,
prepare_update operation of resource is used now. Thus, all other
attributes can be retrieved at same sequence of group list.
Change-Id: I239380864cd05f5ac24017fbee6e02b069538bd0
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Chanwoo Choi [Wed, 23 Mar 2022 04:59:10 +0000 (13:59 +0900)]
util: kernel: Fix overflow with bit operations
Drop 10 MSB bit and 10 left shift operation without multiply operation.
Change-Id: I9cc0d5a3f131686c49757edfc2565f25e6a1ecef
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Wed, 23 Mar 2022 04:54:39 +0000 (13:54 +0900)]
Revert "util: kernel: Fix overflow issue when multiply operation"
This reverts commit
8c98239629e4b49f934de535f881bff26cc52ae9.
Change-Id: I1757a90f63ed45ed6ee1c987f9bc7eb45b4e68fb
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Dongwoo Lee [Tue, 22 Mar 2022 05:34:27 +0000 (14:34 +0900)]
monitor: request-handler: Fix build warning
Change-Id: If5b45861fe807d0c703baf8ae37dcc90ee307389
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Chanwoo Choi [Tue, 22 Mar 2022 05:53:22 +0000 (14:53 +0900)]
lib: tmonitor: Include mandatory header file for variable types
When the client refer to tmonitor.h header file, build error happen
because tmonitor.h doesn't include the 'sys/type.h' header file.
So that include mandatory header file for variable types such as u_int64_t.
Change-Id: I3b69e5a95e644ccc160da8aa2583674c91f3725e
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Dongwoo Lee [Tue, 22 Mar 2022 01:22:46 +0000 (10:22 +0900)]
resource: process: Set attributes as always supported
To support skeleton process resource driver which is representing
process on demand, it should be possible to set interesting attributes
list before set controls. To this end, all attributes in process is
now set to always supported.
Change-Id: Ib595d9093b90c860d9f8fb3922d1d295a9957af8
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 21 Mar 2022 08:21:21 +0000 (17:21 +0900)]
monitor: request-handler: Fix to delete resource properly
Since resources are managed by hash table, it should be removed from
hash table before removing resource. Otherwise, it can cause
double-free when the client is disconnected. So, this fixes create and
remove procedures to handle hash table properly.
Change-Id: I466e5cc6c289c20cd827964aae0c191b85356938
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Chanwoo Choi [Mon, 21 Mar 2022 05:03:21 +0000 (14:03 +0900)]
resource: process: Fix memory leak issue
Change-Id: I15674f225da17e339493327b6ec870c86ad826a7
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Mon, 21 Mar 2022 04:16:50 +0000 (13:16 +0900)]
monitor: request-handler: Replace with strerror_r to fix vulnerability issue
Change-Id: I399fe56e8305df1ed3aef2b7e55677ea2b463313
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Dongwoo Lee [Mon, 14 Mar 2022 01:43:38 +0000 (10:43 +0900)]
resource: Add process group resource driver
This resource is pseudo-device driver which provides information of
related process group.
Controls:
- PROCESS_GROUP_CTRL_ROOT_PID: pid of top-level process in a group
what we want to see.
Atrributes:
- PROCESS_GROUP_ATTR_LIST: array of pid which includes all processes
related with root pid. if root pid is
negative, list contains all processes.
Change-Id: I0b7a85dd7d8f2bd4628e17c8db923dd4abd112a8
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 21 Mar 2022 04:10:15 +0000 (13:10 +0900)]
util: kernel: Fix to close files after use
Change-Id: I91c2869f4c8bcf9ff80bf9691d357088d80dce88
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Tue, 15 Mar 2022 03:45:22 +0000 (12:45 +0900)]
lib: tmonitor: Add get APIs for array type attributes
This adds internal API for getting array type attributes as below:
- tmonitor_get_array_int
- tmonitor_get_array_int64
- tmonitor_get_array_uint
- tmonitor_get_array_uint64
- tmonitor_get_array_double
- tmonitor_get_array_string
Since users get dynamically allocated array with length by just
passing pointer of pointer for each data type, it should be freed
after use.
Change-Id: I8f72ff5c6ceebcc4eda8998f2ad4fed47f71e3d5
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Fri, 11 Mar 2022 10:11:48 +0000 (19:11 +0900)]
resource: process: Add PGID and PPID attributes
Change-Id: I6516546b9e1603095070e02b299f8e904e1aa63f
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 14 Mar 2022 09:33:54 +0000 (02:33 -0700)]
util: kernel: Add functions for getting procfs stat fields
This adds new functions for getting procfs stat fields of certain
process id as like below prototype:
int kernel_get_process_stat_fields(pid_t pid, char *buffer, int buf_len, char **stat_fields)
- pid: target process id
- buffer: string buffer for retrieving procfs stat, each field of
stat_fileds points out some index within this buffer area.
Thus, life time of stat_fields are determined by this.
- buf_len: length of provided buffer
- stat_fields: string array of retrieved fields, this should be
declared as (char *)[PROCESS_STAT_FIELD_MAX] type.
Signed-off-by: Dongwoo Lee <dwlee08@gmail.com>
Change-Id: I23008751fdd17ddd17d9e756e1f0d7394bee5f98
Dongwoo Lee [Tue, 15 Mar 2022 11:19:20 +0000 (20:19 +0900)]
util: Add resource_attr_supported_always() function
This provides common callback to is_supported operation of attribute
for supporting always available attributes.
Change-Id: Iba5058e03cf583693a897684093cf5d35573be33
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Chanwoo Choi [Mon, 14 Mar 2022 07:46:05 +0000 (16:46 +0900)]
util: kernel: Fix overflow issue when multiply operation
Change-Id: Ia9bce7fbc4adabafa76e788d78450ce38866d7cf
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Mon, 14 Mar 2022 02:42:14 +0000 (11:42 +0900)]
resource: process: Check return value of nla_put_u32
Change-Id: I2b31cd1d531d3ca219b535efed5e39c1a1a74698
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Sung-hun Kim [Mon, 14 Mar 2022 01:42:22 +0000 (10:42 +0900)]
resource: memory: Add new attributes for memory resource
MEMORY_ATTR_BUFFER: an information about system I/O buffers
MEMORY_ATTR_CACHED: an information about system page cache
MEMORY_ATTR_CMA_TOTAL: an information about total CMA buffer size
MEMORY_ATTR_CMA_FREE: an information about free CMA buffers
Change-Id: I14fbc69e6f0a015c6137eed89650265b7fdda958
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
Chanwoo Choi [Tue, 8 Mar 2022 10:53:44 +0000 (19:53 +0900)]
lib: tmonior: Implement the missing API
Implement the following tmonitor API:
- tmonitor_delete_resouce() : REQUEST_DELETE_RESOURCE
- tmonitor_get_resouce_count() : REQUEST_GET_RESOURCE_COUNT
- tmonitor_update() : REQUEST_UPDATE_RESOURCE_ALL
- tmonitor_unset_resource_attr : REQUEST_UNSET_RESOURCE_ATTR
- tmoniotr_is_resource_attr_supported() : REQUEST_IS_RESOURCE_ATTR_SUPPORTED
Change-Id: Id068940632c4bbd5bae79d907e77f846fff4a042
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Tue, 8 Mar 2022 07:34:49 +0000 (16:34 +0900)]
lib: tmonitor: Replace the initial tmonitor API to enhanced declaration
Replace the initial tmonitor API to enhanced declaration
and add the declaration of missing tmonitor API.
Change-Id: I8845f9a17e325e13118767943536c5c313828fd9
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Thu, 10 Mar 2022 07:11:29 +0000 (16:11 +0900)]
util: resource: Add is_resource_attr_supported function
is_resource_attr_supported(struct resource *resource, u_int64_t attr_id)
checks whether resource attribute of attr_id is supported or not on
board. In order to check the support of resource attribute, add
.is_supported ops to struct resource_attribute_ops.
But if .is_supported ops is not implemented, use .get ops in order to
check whether the resource attribute is supported or not.
Change-Id: I0b4ed0579c6602e43ff6b3544b4d136707440124
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Fri, 11 Mar 2022 06:46:42 +0000 (15:46 +0900)]
util: resource: Return error for set/unset_resource_attr_interest
Change-Id: I5fe36ff6dd5e38ccdfe64a7d7bb153d22b8d641c
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Tue, 8 Mar 2022 09:21:03 +0000 (18:21 +0900)]
lib: tmonitor: Rename resource attribute name with _ATTR_ word
Rename resource attribute name with _ATTR_ word in order to improve
the readability and remove un-implemented attributes.
And fix minor coding style.
Change-Id: I9029ff3b49a57381ce763894014c7a3cc9357860
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Dongwoo Lee [Mon, 7 Mar 2022 10:25:49 +0000 (19:25 +0900)]
tmonitor: Implement additional get data functions
Change-Id: I94a3cb2950a44c8c7a2039341d2795fbce89480b
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 10 Mar 2022 11:32:21 +0000 (20:32 +0900)]
util: resource: Allocate storage for attribute data at set interest
This introduces the new way to using attribute value. Instead of
allocate memory for each attribute value by driver-self, memory is
allocated when client sets interest for each attribute. This can
prevent from unnecessary memory allocation by deferring until it is
really required.
Change-Id: Ie6d47db4c6735510a0e784f8c254705c2c176b25
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 7 Mar 2022 08:48:49 +0000 (17:48 +0900)]
util: resource: Rework double type attributes
To support double type attributes with exact precison, instead of
casting double to void pointer, using double type allocated memory
as like string or array.
Change-Id: Ie432026f02ad0d22b98a24fdeed7ae1ddf5440ef
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 10 Mar 2022 07:16:23 +0000 (16:16 +0900)]
util: resource: Fix type check errors
Change-Id: Ie4f3a00893aa4c3a87c5e83eb763135efc965cf1
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 10 Mar 2022 03:15:56 +0000 (12:15 +0900)]
monitor: handler: Fix wrong argument type
Change-Id: Iae4bee8a05313ff1ebd4e1de1892c7bf37af8c71
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 10 Mar 2022 07:44:39 +0000 (16:44 +0900)]
monitor: request-handler: Handle negative return value of recv
Change-Id: I4a84b3f834fbc4f036f28597aa34f0bceb9d6c5c
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 10 Mar 2022 02:57:04 +0000 (11:57 +0900)]
monitor: request: Remove unused request name array
Change-Id: Idb1b47964b08b0fefeee8f4bec4eff201c896d0e
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Sung-hun Kim [Thu, 10 Mar 2022 06:55:12 +0000 (15:55 +0900)]
monitor: Replace vulnerable sprintf to snprintf
Change-Id: I6baf894343dfa1db050bdf5ac20af735dc7c5185
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
Sung-hun Kim [Thu, 10 Mar 2022 05:52:55 +0000 (14:52 +0900)]
monitor: rename the member of request_client
Previously, client->id is used as a socket descriptor.
It can be a confused situation for future readers. So,
rename it to client->socket_fd to reveal the intention
of the member variable.
Change-Id: I3512da878b412f3b8aa5821c70de254bf5cd64bb
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
Sung-hun Kim [Thu, 10 Mar 2022 03:42:57 +0000 (12:42 +0900)]
monitor: remove an unnecessary mutex in request_client
resource_table in request_client is only accessed by
the owner thread. Thus, such member does not need to
be protected from concurrent accesses.
Change-Id: I942e9b8a8de3a0bfb1d3a33fc249ebc1c3f2cb56
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
Dongwoo Lee [Mon, 7 Mar 2022 07:49:04 +0000 (16:49 +0900)]
lib: tmonitor: Implement tmonitor APIs
Tmonitor provides resource monitoring feature by using socket
connection. This is the first version of that implements a
subset of a tmonitor API set.
Change-Id: I9174ba3849f0eae069ace34e9a1b26be0064a436
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 7 Mar 2022 07:50:11 +0000 (16:50 +0900)]
monitor: Add request-server and request-handler-thread
To provide libpass API via socket, a manager is required to
manage network connections and requests from clients.
Request-server is a manager to manage network connections.
It accepts and establishes a socket connection from each
client, then spawns a per-client request-handler-thread to
deal with incoming requests from the client if required.
Change-Id: I17cdf1fde69022663c2369b55982ac43e5b5c688
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 3 Mar 2022 11:42:40 +0000 (20:42 +0900)]
util: resource: Give unique id for each resource
Change-Id: I9f4eb44862ed42a2189d1c1f6cac47e760b876fe
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Thu, 24 Feb 2022 11:40:11 +0000 (20:40 +0900)]
resource: Rework resource creation and initialization
Change-Id: I386e277a20418b4030d3d5a63dcf10ea15898c6c
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 28 Feb 2022 09:02:10 +0000 (18:02 +0900)]
util: thread: Support free function for destorying queue
Since lock-free queue can have various data type, users can pass free
function when creating queue along with the corresponding data type in
queue.
Change-Id: I4ede38bd6e36a1622bb39c7183829c5372e3264b
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 28 Feb 2022 05:29:14 +0000 (14:29 +0900)]
util: kernel: Use 64-bit unsigned integer for memory information
Since memory information node of kernel can be presented with 32-bit
signed variable as maximum 2GB, to overcome this limitation, this
changes related functions using 64-bit unsigned integer variable.
Change-Id: Id1b1da468ca5e7c98cd65318c854cd5a98ae2086
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 28 Feb 2022 03:46:25 +0000 (12:46 +0900)]
resource: Distinguish signed/unsigned and 32/64 bits integer data types
To provide clients with the precise integer values, now support the new
data types:
- DATA_TYPE_INT(32-bit signed integer),
- DATA_TPYE_INT64(64-bit signed integer),
- DATA_TYPE_UINT(32-bit unsigned integer),
- DATA_TPYE_UINT64(64-bit unsigned integer),
Change-Id: I8f70fb38a1fd9876b53d52c2f7592120fc0f9b5c
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Chanwoo Choi [Mon, 28 Feb 2022 05:41:36 +0000 (14:41 +0900)]
util: kernel: Fix STATIC_OVERFLOW issue
Change-Id: Ic8118a695865913f06da029a47278cccfd266c09
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Seung-Woo Kim [Mon, 28 Feb 2022 03:42:53 +0000 (12:42 +0900)]
resource: system: avoid possible use-after-free in error path
In error path, assigned pointer is not cleared after free. Fix
to avoid possible use-after-free with the not cleared pointer.
Change-Id: Idaa222afc9660e68cc5021bd251f21cd47e30b97
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Chanwoo Choi [Mon, 28 Feb 2022 03:03:36 +0000 (12:03 +0900)]
resource: system: Fix NULL_AFTER_DEREF issue
Change-Id: I9d25da863b004e11a71e0a44d7f8a0aebb22bc2c
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Chanwoo Choi [Fri, 25 Feb 2022 10:35:46 +0000 (19:35 +0900)]
resource: Fix build warning for memory/process resource driver
- Build warning 1
src/resource/resource-memory.c:42:10: warning: implicit declaration
of function 'kernel_get_memory_total' [-Wimplicit-function-declaration]
[ 11s] 42 | return kernel_get_memory_total();
[ 11s] | ^~~~~~~~~~~~~~~~~~~~~~~
src/resource/resource-memory.c:44:10: warning: implicit declaration
of function 'kernel_get_memory_info' [-Wimplicit-function-declaration]
[ 11s] 44 | return kernel_get_memory_info(PROC_MEM_INFO_MEM_AVAILABLE);
- Build warning 2
src/resource/resource-process.c:452:19: warning: unused variable 'memory' [-Wunused-variable]
[ 12s] 452 | struct resource *memory;
Change-Id: I2a473453fb02fc7dd1eb8319474fe9e8633ea2a0
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Dongwoo Lee [Wed, 23 Feb 2022 09:16:16 +0000 (18:16 +0900)]
pass: Add capability for netlink interface
Due to CVE-2011-2494 which prohibits non-privileged users from getting
process information via netlink, pass daemon should be executed by
root or get capability on NET_ADMIN. To do this, it adds capability
into systemd service attribute with cap_net_admin.
Change-Id: Iefd4ca98e963b38a038a8c326f3abad996bb81ee
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Tue, 22 Feb 2022 06:21:32 +0000 (15:21 +0900)]
resource: process: Add new PROCESS_COMM and PROCESS_MEM_PERCENT attributes
This introduces the new attributes as follows:
PROCESS_COMM: shows the name of process.
PROCESS_MEM_PERCENT: shows ratio of process rss against system memory.
Change-Id: Ia50715204c4195deed3b469798f3626a2ea45d5c
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Wed, 23 Feb 2022 08:39:57 +0000 (17:39 +0900)]
util: kernel: export apis for getting memory info
Change-Id: Ibd7c78f61de9ffcc8b9635a42c779af550c61124
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Wed, 23 Feb 2022 07:58:04 +0000 (16:58 +0900)]
util: kernel: Read stationary values once
Since statinary kernel sysfs or procfs nodes is not have to be
read every time, it lets them being read once.
Change-Id: Icee5f825694867ecb84847fd46830274fe8219d3
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Mon, 21 Feb 2022 07:22:01 +0000 (16:22 +0900)]
resource: process: Handle pid, tgid into parsing nla types
To prevent pid, tgid is considered error case, add handling of them.
Change-Id: I3ef127312e860f8bf625a8427d5e40cfb68196cc
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Dongwoo Lee [Fri, 4 Feb 2022 06:54:46 +0000 (15:54 +0900)]
resource: Add process resource driver
Process resource driver provides information about process using
procfs and taskstats.
[Detailed description of added system attributes]
PROCESS_CPU_UTIL: It shows cpu usage including its all threads.
PROCESS_MEM_VIRT: It shows all memory that the process can
access, including memory that is swapped out,
memory that is allocated, but not used, and
memory that is from shared libraries.
PROCESS_MEM_RSS: It shows how much memory is allocated to that
process and is in RAM.
PROCESS_DISK_READ: It shows acutal disk read bytes per second.
PROCESS_DISK_WRITE: It shows acutal disk write bytes per second.
Change-Id: Iab4a76334fc786f068cbee396f3896184cbfff47
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>