Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Applicable to: OpenHarmony SDK 3.2.3.5, stage model of API version 9
Run the hdc_std command to copy the .db, .db-shm, and .db-wal files from **/data/app/el2/100/database/Bundle name/entry/db/**, and then use the SQLite tool to open the files.
Run the hdc_std command to copy the .db, .db-shm, and .db-wal files in **/data/app/el2/100/database/*bundleName*/entry/db/**, and then use the SQLite tool to open the files.
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
The distributed data service (DDS), relational database (RDB) store, and preferences provided OpenHarmony have a lock mechanism. You do not need to bother with the lock mechanism during the development.
## What Is a Transaction in an RDB Store?
Applicable to: all versions
When a large number of operations are performed in an RDB store, an unexpected exception may cause a failure of some data operations and loss of certain data. As a result, the application may become abnormal or even crash.
A transaction is a group of tasks serving as a single logical unit. It eliminates the failure of some of the operations and loss of associated data.
## What Data Types Does an RDB Store Support?
Applicable to: OpenHarmony SDK 3.0 or later, stage model of API version 9
An RDB store supports data of the number, string, and Boolean types. The number array supports data of the Double, Long, Float, Int, or Int64 type, with a maximum precision of 17 decimal digits.
## How Do I View Database db Files?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
1. Run the **hdc_std shell** command.
2. Obtain the absolute path or sandbox path of the database.
The absolute path is **/data/app/el2/<userId>/database/<bundleName>**. The default **<userId>** is **100**.
To obtain the sandbox path, run the **ps -ef | grep hapName** command to obtain the process ID of the application.
The database sandbox path is **/proc/<Application process ID>/root/data/storage/el2/database/**.
3. Run the **find ./ -name "\*.db"** command in the absolute path or sandbox path of the database.
## How Do I Store Long Text Data?
Applicable to: OpenHarmony SDK 3.2.5.5, API version 9
- Preferences support a string of up to 8192 bytes.
- The KV store supports a value of up to 4 MB.
Reference: [Preference Overview](../database/database-preference-overview.md) and [Distributed Data Service Overview](../database/database-mdds-overview.md)
## How Do I Develop DataShare on the Stage Model
Applicable to: OpenHarmony SDK 3.2.5.5, API version 9
The DataShare on the stage model cannot be used with the **DataAbility** for the FA model. The connected server application must be implemented by using **DataShareExtensionAbility**.
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
## What If There is No Return Value or Error Captured After getAlbums Is Called?
Yes. **fileio.rmdir** deletes files recursively.
## How Do I Create a File That Does Not Exist?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
You can use **fileio.open(filePath, 0o100, 0o666)**. The second parameter **0o100** means to create a file if it does not exist. The third parameter **mode** must also be specified.
## What If "call fail callback fail, code: 202, data: json arguments illegal" Is Displayed?
Applicable to: OpenHarmony SDK 3.2.6.3, stage model of API version 9
When the **fileio** module is used to copy files, the file path cannot start with "file:///".
## How Do I Read Files Outside the App Sandbox?
Applicable to: OpenHarmony SDK 3.2.6.5, stage model of API version 9
If the input parameter of the **fileio** API is **path**, only the sandbox directory of the current app obtained from the context can be accessed. To access data in other directories such as the user data, images, and videos, open the file as the data owner and operate with the file descriptor (FD) returned.
For example, to read or write a file in Media Library, perform the following steps:
1. Use **getFileAssets()** to obtain the **fileAsset** object.
2. Use **fileAsset.open()** to obtain the FD.
3. Use the obtained FD as the **fileIo** API parameter to read and write the file.
## What If the File Contains Garbled Characters?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
Read the file content from the buffer, and decode the file content using **util.TextDecoder**.
## What Should I Do If There Is No Return Value or Error Captured After getAlbums Is Called?
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
Applicable to: OpenHarmony SDK 3.2.5.3, stage model of API version 9
The **ohos.permission.READ_MEDIA**permission is required for calling **getAlbums**, and this permission needs user authorization. For details, see OpenHarmony [Application Permission List](../security/permission-list.md).
The **ohos.permission.READ_MEDIA**is required for using **getAlbums()**. In addition, this permission needs user authorization. For details, see [OpenHarmony Permission List](../security/permission-list.md).
1. Configure the required permission in the **module.json5** file.
1. Configure the required permission in the **module.json5** file.
...
@@ -34,3 +84,21 @@ The **ohos.permission.READ_MEDIA** permission is required for calling **getAlbum
...
@@ -34,3 +84,21 @@ The **ohos.permission.READ_MEDIA** permission is required for calling **getAlbum
})
})
}
}
```
```
## What Do I Do If the App Crashes When FetchFileResult() Is Called Multiple Times?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
Each time after the **FetchFileResult** object is called, call **FetchFileResult.close()** to release and invalidate the **FetchFileResult** object .
## What If An Error Is Reported by IDE When mediaLibrary.getMediaLibrary() Is Called in the Stage Model?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
In the stage model, use **mediaLibrary.getMediaLibrary(context: Context)** to obtain the media library instance.
## How Do I Sort the Data Returned by mediaLibrary.getFileAssets()?
Applicable to: OpenHarmony SDK 3.2.5.5, stage model of API version 9
Use the **order** attribute in **[MediaFetchOptions](../reference/apis/js-apis-medialibrary.md#mediafetchoptions7)** to sort the data returned.
The OpenHarmony codec Hardware Device Interface (HDI) driver framework implements the video hardware codec driver based on OpenMAX. It provides APIs for the upper-layer media services to obtain component encoding and decoding capabilities, create a component, set parameters, transfer data, and destroy a component. The codec driver can encode video data in YUV or RGB format to H.264 or H.265 format, and decode raw stream data from H.264 or H.265 format to YUV or RGB format. This document describes the codec functionality developed based on the OpenHarmony Hardware Driver Foundation (HDF).
The codec Hardware Device Interface (HDI) driver framework is implemented based on OpenHarmony Hardware Driver Foundation (HDF). The HDI driver framework implements the video hardware codec driver based on OpenMAX. It provides APIs for the upper-layer media services to obtain component encoding and decoding capabilities, create a component, set parameters, transfer data, and destroy a component. The codec driver can encode video data in YUV or RGB format to H.264 or H.265 format, and decode raw stream data from H.264 or H.265 format to YUV or RGB format.
The codec HDI driver framework is implemented based on the HDF. The figure below shows the codec HDI driver framework.
The figure below shows the codec HDI driver framework.
**Figure 1** Codec HDI driver framework
**Figure 1** Codec HDI driver framework
...
@@ -16,7 +16,7 @@ The codec HDI driver framework is implemented based on the HDF. The figure below
...
@@ -16,7 +16,7 @@ The codec HDI driver framework is implemented based on the HDF. The figure below
- Codec HDI Adapter: HDI implementation layer, which implements HDI APIs and interacts with OpenMAX Integration layer (IL).
- Codec HDI Adapter: HDI implementation layer, which implements HDI APIs and interacts with OpenMAX Integration layer (IL).
- OpenMAX IL interface: provides OpenMAX IL APIs to directly interact with the codec HDI driver.
- OpenMAX IL interface: provides OpenMAX IL APIs to directly interact with the codec HDI driver.
- Vendor Impl: vendor adaptation layer, which is the OpenMAX implementation layer adapted by each vendor.
- Vendor Impl: vendor adaptation layer, which is the OpenMAX implementation layer adapted by each vendor.
- Codec Hardware: hardware decoding device.
- Codec Hardware: hardware coding and decoding device.
### Basic Concepts
### Basic Concepts
Before you get started, understand the following concepts:
Before you get started, understand the following concepts:
...
@@ -39,7 +39,7 @@ Before you get started, understand the following concepts:
...
@@ -39,7 +39,7 @@ Before you get started, understand the following concepts:
- Component
- Component
An OpenMAX IL component, which is an abstraction of modules in video streams. The components in this document refer to codec components for video encoding and decoding.
An OpenMAX IL component, which is an abstraction of modules in video streams. The components in this document refer to codec components used for video encoding and decoding.
### Constraints
### Constraints
...
@@ -59,7 +59,7 @@ The codec module implements hardware encoding and decoding of video data. It con
...
@@ -59,7 +59,7 @@ The codec module implements hardware encoding and decoding of video data. It con
| int32_t (*UseBuffer)(struct CodecComponentType *self, uint32_t portIndex, struct OmxCodecBuffer *buffer) | Specifies the buffer of a component port. |
| int32_t (*UseBuffer)(struct CodecComponentType *self, uint32_t portIndex, struct OmxCodecBuffer *buffer) | Requests a port buffer for the component. |
@@ -88,7 +88,7 @@ For more information, see [codec](https://gitee.com/openharmony/drivers_peripher
...
@@ -88,7 +88,7 @@ For more information, see [codec](https://gitee.com/openharmony/drivers_peripher
The codec HDI driver development procedure is as follows:
The codec HDI driver development procedure is as follows:
#### Registering and Initializing the Driver
#### Registering and Initializing the Driver
Define the **HdfDriverEntry** structure (which defines the driver initialization method) and fill in the **g_codecComponentDriverEntry** structure to implement the **Bind()**, **Init()**, and **Release()** pointers.
Define the **HdfDriverEntry** structure (which defines the driver initialization method) and fill in the **g_codecComponentDriverEntry** structure to implement the pointers in **Bind()**, **Init()**, and **Release()**.
```c
```c
structHdfDriverEntryg_codecComponentDriverEntry={
structHdfDriverEntryg_codecComponentDriverEntry={
...
@@ -133,7 +133,7 @@ HDF_INIT(g_codecComponentDriverEntry); // Register HdfDriverEntry of the codec H
...
@@ -133,7 +133,7 @@ HDF_INIT(g_codecComponentDriverEntry); // Register HdfDriverEntry of the codec H
}
}
```
```
-**HdfCodecComponentTypeDriverInit**: loads the attribute configuration from the HDF configuration source (HCS).
-**HdfCodecComponentTypeDriverInit**: loads the attribute configuration in the HDF Configuration Source (HCS).
@@ -170,12 +170,11 @@ The HCS consists of the following:
...
@@ -170,12 +170,11 @@ The HCS consists of the following:
- Device configuration
- Device configuration
- Configuration of the supported components
- Configuration of the supported components
The HCS includes the driver node, loading sequence, and service name. For details about the HCS syntax, see [Configuration Management](driver-hdf-manage.md).
You need to configure the driver node, loading sequence, and service name. For details about the HCS syntax, see [Configuration Management](driver-hdf-manage.md).
Configuration file Path of the standard system:
The following uses the RK3568 development board as an example. The configuration files of the standard system are in the **vendor/hihope/rk3568/hdf_config/uhdf/** directory.
vendor/hihope/rk3568/hdf_config/uhdf/
1.Device configuration
1.Configure the device.
Add the **codec_omx_service** configuration to **codec_host** in **device_info.hcs**. The following is an example:
Add the **codec_omx_service** configuration to **codec_host** in **device_info.hcs**. The following is an example:
After completing codec module driver adaptation, use the HDI APIs provided by the codec module for further development. The codec HDI provides the following features:
After completing codec module driver adaptation, use the HDI APIs provided by the codec module for further development. The codec HDI provides the following features:
1. Provides codec HDI APIs for video services to implement encoding and decoding of video services.
1. Provides codec HDI APIs for video services to implement encoding and decoding for video services.
2. Provides standard interfaces for device developers to ensure that the OEM vendors comply with the HDI adapter standard. This promises a healthy evolution of the ecosystem.
2. Provides standard interfaces for device developers to ensure that the OEM vendors comply with the HDI adapter standard. This promises a healthy evolution of the ecosystem.
The development procedure is as follows:
The development procedure is as follows:
...
@@ -248,7 +247,7 @@ The development procedure is as follows:
...
@@ -248,7 +247,7 @@ The development procedure is as follows:
2. Set codec parameters and information such as the video width, height, and bit rate.
2. Set codec parameters and information such as the video width, height, and bit rate.
3. Apply for input and output buffers.
3. Apply for input and output buffers.
4. Flip codec buffers, enable the component to enter the **OMX_Executing** state, and process the callbacks.
4. Flip codec buffers, enable the component to enter the **OMX_Executing** state, and process the callbacks.
5. Deinitialize the interface instance, destroy the buffers, close the component, and releases all interface objects.
5. Deinitialize the interface instance, destroy the buffers, close the component, and releases all interface instances.
#### Initializing the Driver
#### Initializing the Driver
Initialize the interface instance and callbacks, and create a component.
Initialize the interface instance and callbacks, and create a component.
...
@@ -352,7 +351,7 @@ Perform the following steps:
...
@@ -352,7 +351,7 @@ Perform the following steps:
1. Use **UseBuffer()** to apply for input and output buffers and save the buffer IDs. The buffer IDs can be used for subsequent buffer flipping.
1. Use **UseBuffer()** to apply for input and output buffers and save the buffer IDs. The buffer IDs can be used for subsequent buffer flipping.
2. Check whether the corresponding port is enabled. If not, enable the port first.
2. Check whether the corresponding port is enabled. If not, enable the port first.
3. Use **SendCommand()** to change the component status to OMX_StateIdle, and wait until the operation result is obtained.
3. Use **SendCommand()** to change the component status to **OMX_StateIdle**, and wait until the operation result is obtained.
Automatic framing is not supported in rk OMX decoding. Therefore, you need to manually divide data into frames. Currently, data is divided into frames from code 0x000001 or 0x00000001 and sent to the server for processing. The sample code is as follows:
The RK3568 development board does not support data framing. Therefore, you need to manually divide the data into frames. Data is divided from code 0x000001 or 0x00000001 and sent to the server for processing. The sample code is as follows:
-**EventHandler**: Called when a command is executed. For example, when the command for changing the component state from **OMX_StateIdle** to **OMX_StateExecuting** is executed, this callback is invoked to return the result.
-**EventHandler**: Called when a command is executed. For example, when the command for changing the component state from **OMX_StateIdle** to **OMX_StateExecuting** is executed, this callback is invoked to return the result.
-**EmptyBufferDone**: Called when the input data is consumed. If the client needs to fill in data to encode or decode, call **EmptyThisBuffer()**.
-**EmptyBufferDone**: Called when the input data is consumed. If the client needs to fill data to encode or decode, it must call **EmptyThisBuffer()** again.
-**FillBufferDone**: Called when the output data is filled. If the client needs to read the encoded or decoded data, call **FillThisBuffer()**.
-**FillBufferDone**: Called when the output data is filled. If the client needs to read the encoded or decoded data, it must call **FillThisBuffer()** again.
Change the component state to IDLE, release the input and output buffers, change the component state to **OMX_StateLoaded**, and call **DestoryComponent** to destroy the component.
Change the component state to **OMX_StateIdle**, release the input and output buffers, change the component state to **OMX_StateLoaded**, and call **DestoryComponent** to destroy the component.
##### Example of Releasing Buffers
##### Example of Releasing Buffers
...
@@ -721,7 +719,7 @@ OpenMAX does not support framing.
...
@@ -721,7 +719,7 @@ OpenMAX does not support framing.
**Solution**
**Solution**
Transfer data frame by frame when **EmptyThisBuffer** is called.
Pass in one frame at a time when **EmptyThisBuffer** is call.
## Only Green Screen Displayed During the Decoding Process
## Only Green Screen Displayed During the Decoding Process
...
@@ -751,11 +749,11 @@ After the generated video stream (H.264 stream) is written to a file, the video
...
@@ -751,11 +749,11 @@ After the generated video stream (H.264 stream) is written to a file, the video
**Solution**
**Solution**
View the **codec_host** log generated during encoding, search for "encode params init settings", and check for incorrect parameters. If **framerate** is **0**, **xFramerate** is incorrectly set. In this case, move the framerate leftwards by 16 bits.
View the **codec_host** log generated during encoding, search for "encode params init settings", and check for incorrect parameters. If **framerate** is **0**, **xFramerate** is incorrectly set. In this case, move the framerate leftwards by 16 bits.
Check the value of **OMX_VIDEO_PARAM_AVCTYPE**, and set it correctly.
Check and correct the setting of **OMX_VIDEO_PARAM_AVCTYPE**.
# Reference
# Reference
For more information, see [Codec](https://gitee.com/openharmony/drivers_peripheral/tree/master/codec).
For more information, see [codec](https://gitee.com/openharmony/drivers_peripheral/tree/master/codec).
> Enable ESwap before zram is enabled. If ESwap is not used, you can enable zram alone. If a device does not have the storage device for swap-out or have the corresponding storage partition created, you can enable zram to reclaim memory using **zswapd**.
### Enabling ESwap
### Enabling ESwap
1. Enable related configuration items and dependencies.
1. Enable related configuration items and dependencies.
To enable ESwap, you must enable the corresponding configuration items and dependencies during kernel compilation. The configuration items related to ESwap are as follows:
To enable ESwap, you must enable the corresponding configuration items and dependencies during kernel compilation. The configuration items related to ESwap are as follows:
CONFIG_HYPERHOLD_MEMCG=y // Enable Memcg management in Hyperhold
CONFIG_ZRAM_GROUP=y
CONFIG_ZRAM_GROUP=y // Enable Manage Zram objs with mem_cgroup
CONFIG_ZRAM_GROUP_DEBUG=y
CONFIG_ZRAM_GROUP_DEBUG=y // Enable Manage Zram objs with mem_cgroup Debug
CONFIG_ZLIST_DEBUG=y
CONFIG_ZLIST_DEBUG=y // Enable Debug info for zram group list
CONFIG_ZRAM_GROUP_WRITEBACK=y
CONFIG_ZRAM_GROUP_WRITEBACK=y // Enable write back grouped zram objs to Hyperhold driver
```
```
Enable the following dependencies:
Enable the following dependencies:
```
```
CONFIG_MEMCG=y
CONFIG_MEMCG=y // Enable memory controller
CONFIG_SWAP=y
CONFIG_SWAP=y // Enable paging of anonymous memory (swap)
CONFIG_ZSMALLOC=y
CONFIG_ZSMALLOC=y // Enable memory allocator for compressed pages
CONFIG_ZRAM=y
CONFIG_ZRAM=y // Enable compressed RAM block device support
```
```
2. Create an ESwap device.
2. Create an ESwap device.
...
@@ -56,11 +59,11 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
...
@@ -56,11 +59,11 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
By default, ESwap encrypts the data swapped out. If the ESwap device created in step 2 supports inline encryption, you can disable the ESwap software encryption function.
By default, ESwap encrypts the data swapped out. If the ESwap device created in step 2 supports inline encryption, you can disable the ESwap software encryption function.
```Bash
```Bash
// Check whether hardware-based encryption is supported and enabled. If yes, disable software encryption. Otherwise, do not perform this operation.
// Check whether hardware-based encryption is supported and enabled. If yes, disable software encryption. Otherwise, do not disable software encryption.
> For security purposes, all swapped content must be encrypted. If the ESwap device created does not support inline encryption or the inline encryption macro is not enabled during compilation, ESwap cannot be enabled after software encryption is disabled.
> For security purposes, all swapped content must be encrypted. If the ESwap device created does not support inline encryption or the inline encryption macro is not enabled during compilation, ESwap cannot be enabled after software encryption is disabled.
4. Enable ESwap.
4. Enable ESwap.
...
@@ -72,9 +75,6 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
...
@@ -72,9 +75,6 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
> Enable ESwap before zram is enabled. If ESwap is not used, you can enable zram only. If a device does not have the storage device for swap-out or have the corresponding storage partition created, you can enable zram to reclaim memory using **zswapd**.
### Enabling zram
### Enabling zram
1. Initialize zram.
1. Initialize zram.
...
@@ -88,7 +88,7 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
...
@@ -88,7 +88,7 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
> The difference of the two commands is as follows:
> The difference of the two commands is as follows:
>
>
> - **disable**: If there is no data in the ESwap partition, disable ESwap. Otherwise, changes ESwap to **readonly** mode.
> - **disable**: If there is no data in the ESwap partition, disable ESwap. Otherwise, changes ESwap to **readonly** mode.
...
@@ -132,42 +132,46 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
...
@@ -132,42 +132,46 @@ Enhanced Swap (ESwap) allows a custom partition to serve as a swap partition and
## ESwap APIs
## ESwap APIs
ESwap provides APIs to control swap-in and swap-out policies and record the current status. These APIs are located in the directory to which memcg is mounted, for example, `/dev/memcg/`.
ESwap provides APIs to control swap-in and swap-out policies and record the current status. These APIs are located in the directory to which memcg is mounted, for example, **/dev/memcg/**.
| Category| API| Description|
| Category| API| Description| Reference Value|
| -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| Control| [avail_buffers](#avail_buffers) | Sets the buffer range.|
> Only **avail_buffers** proactively wakes up zswapd because the buffer waterline is adjusted. Other control APIs do not proactively wake up zswapd, but their configuration takes effect only after zswapd is woken up.
> Only **avail_buffers** proactively wakes up zswapd because the buffer waterline is adjusted. Other control APIs do not proactively wake up zswapd, but their configuration takes effect only after zswapd is woken up.
The APIs are described as follows:
### avail_buffers
### avail_buffers
The **avail_buffers** API sets the buffer range [min_avail_buffers, high_avail_buffers]. When the current buffer is less than the value of **min_avail_buffers**, zswapd will be woken up to reclaim anonymous pages. The expected amount of memory to reclaim is the difference between the value of **high_avail_buffers** and the current system buffer value. In fact, less memory is reclaimed due to reasons such as reclamation failure.
The **avail_buffers** API sets the buffer range [min_avail_buffers, high_avail_buffers]. When the current buffer is less than the value of **min_avail_buffers**, zswapd will be woken up to reclaim anonymous pages. The expected amount of memory to reclaim is the difference between the value of **high_avail_buffers** and the current system buffer value. In fact, less memory is reclaimed due to reasons such as reclamation failure.
The parameters include the following:
The parameters include the following:
-**avail_buffers** indicates the expected buffer value.
-**avail_buffers** indicates the expected buffer value.
-**free_swap_threshold** indicates the threshold of the free capacity of the swap partition. After zswapd is woken up to reclaim memory, press events, such as medium press and critical press, will be recorded based on the current system status and the settings of these two parameters.
-**free_swap_threshold** indicates the threshold of the free capacity of the swap partition. After zswapd is woken up to reclaim memory, press events, such as medium press and critical press, will be recorded based on the current system status and the settings of these two parameters.
You can proactively adjust the values to trigger zswapd reclamation.
You can proactively adjust the values to trigger zswapd reclamation.
@@ -207,17 +215,21 @@ The values are all integers.
...
@@ -207,17 +215,21 @@ The values are all integers.
### zram_wm_ratio
### zram_wm_ratio
The **zram_wm_ratio** API sets the zram swap-out waterline. When the size of the compressed anonymous page in the zram partition is greater than the total size of zram multiplied by **zram_wm_ratio**, the page is swapped out to the ESwap partition. The swap is performed after zswapd is woken up by the buffer waterline. The system defaults the value **0** as **37**. You can change the value as required.
**zram_wm_ratio** sets the zram swap-out waterline. When the size of the compressed anonymous page in the zram partition is greater than the total size of zram multiplied by **zram_wm_ratio**, the page is swapped out to the ESwap partition. The swap is performed after zswapd is woken up by the buffer waterline. The system defaults the value **0** as **37**.
Example:
You can change the value as required.
**Example**:
`echo 30 > /dev/memcg/memory.zram_wm_ratio`
`echo 30 > /dev/memcg/memory.zram_wm_ratio`
Default value:
**Default value**:
```
```
zram_wm_ratio: 0
zram_wm_ratio: 0
```
```
Limit:
**Limit**:
0<=zram_wm_ratio<=100
0<=zram_wm_ratio<=100
...
@@ -225,7 +237,7 @@ The value is an integer.
...
@@ -225,7 +237,7 @@ The value is an integer.
### zswapd_pressure_show
### zswapd_pressure_show
The **zswapd_pressure_show** API records the zswapd status. **buffer_size** indicates the current buffer size of the system, and **recent_refault** indicates the number of refaults occurred.
**zswapd_pressure_show** records the zswapd status. **buffer_size** indicates the current buffer size of the system, and **recent_refault** indicates the number of refaults occurred.
### stat
### stat
...
@@ -235,12 +247,12 @@ In addition to **memcg.stat**, the **stat** API is added with **Anon**, **File**
...
@@ -235,12 +247,12 @@ In addition to **memcg.stat**, the **stat** API is added with **Anon**, **File**
### zswapd_vmstat_show
### zswapd_vmstat_show
The **zswapd_vmstat_show** API records events occurred during the zswapd running.
**zswapd_vmstat_show** records events occurred during the zswapd running.
## Triggering zswapd
## Triggering zswapd
You can check the current buffer value by running `cat /dev/memcg/memory.zswapd_pressure_show`. For example, if the current buffer value is 1200, you can adjust the buffer range to wake up zswapd.
You can run **cat /dev/memcg/memory.zswapd_pressure_show** to check the current buffer value. For example, if the current buffer value is 1200, you can adjust the buffer range to a value greater than 1200 to wake up zswapd.
The standard-system devices come with application processors and memory greater than 128 MiB. OpenHarmony uses the Linux kernel as the base kernel so that appropriate OS kernels can be provided for devices with different resource limitations.
OpenHarmony adopts the Linux kernel as the basic kernel for standard-system devices \(reference memory ≥ 128 MiB\) so that appropriate OS kernels can be selected for the devices subject to resource limitations and therefore provide basic capabilities for upper-layer apps.
## Linux Kernel Versions
## Linux Kernel Versions
Linux kernel versions are classified into the stable version and long-term support \(LTS\) version.
- Linux kernel versions are classified into the stable version and long-term support (LTS) version.
The stable version is released approximately every 3 months to support the latest hardware, improve performance, and fix bugs. Its disadvantage is that the overall maintenance lifespan is short, making long-term stable support unavailable for software.
-The stable version is released approximately every 3 months to support the latest hardware, improve performance, and fix bugs. Its disadvantage is that the overall maintenance lifespan is short, making long-term stable support unavailable for software.
The LTS version provides long-term kernel maintenance \(in fixing bugs and security vulnerabilities\). Generally, the maintenance lifespan is six years. By contrast, non-LTS kernel versions whose maintenance lifespan ranges from six months to two years cannot cover the entire lifespan of their products and may leave the products open to security vulnerabilities. In addition, new features are not added in the LTS version update, which ensures the version stability. Therefore, LTS versions are more suitable for commercial products that pursue stability and security.
## OpenHarmony Kernel Version Selection
- The LTS version provides long-term kernel maintenance (in fixing bugs and security vulnerabilities). Generally, the maintenance lifespan is six years. By contrast, non-LTS kernel versions whose maintenance lifespan ranges from six months to two years cannot cover the entire lifespan of their products and may leave the products open to security vulnerabilities. In addition, new features are not added in the LTS version update, which ensures the version stability. Therefore, LTS versions are more suitable for commercial products that pursue stability and security.
The Linux kernel in OpenHarmony selects appropriate LTS versions as its basic versions. Currently, it supports Linux-4.19 and Linux-5.10.
## OpenHarmony Kernel Versions
OpenHarmony uses Linux LTS versions as its base kernel. Currently, it supports Linux-4.19 and Linux-5.10.
Apply the HDF patches based on the kernel version. For details, see [kernel.mk](https://gitee.com/openharmony/kernel_linux_build/blob/master/kernel.mk).
Apply the HDF patches based on the kernel version in the **kernel/linux/build** repository. For details, see the method for applying the HDF patch in **kernel.mk**.
2. Apply the chip driver patch. The following uses Hi3516D V300 as an example.
Place the chip component patches in the related directory. For details about the patch directory and naming rules, see [kernel.mk](https://gitee.com/openharmony/kernel_linux_build/blob/master/kernel.mk).
The following uses Hi3516D V300 as an example:
```makefile
In the **kernel/linux/build** repository, place the chip module patches in the corresponding path based on the patch path and naming rules for the chip module in **kernel.mk**.
Place the chip component **config** in the related directory. For details about the patch directory and naming rules, see [kernel.mk](https://gitee.com/openharmony/kernel_linux_build/blob/master/kernel.mk).
```
```makefile
3. Modify the **config** file to be built.
In the **kernel/linux/build** repository, place the chip module **config** file in the corresponding path based on the file path and naming rules for the chip module in **kernel.mk**.
>In the OpenHarmony project build process, patches are applied after the code environment of **kernel/linux/linux-\*.\*** is copied. Before running the OpenHarmony version-level build command, ensure that the source code environment of **kernel/linux/linux-\*.\*** is available.
> In the OpenHarmony project build process, patches are installed after "kernel/linux/linux-\*.\*" is copied. Before using the version-level build command of OpenHarmony, ensure that the "kernel/linux/linux-\*.\*" source code is available.
>After the build is complete, the kernel is generated in the kernel directory in the **out** directory. Modify the **config** file based on the kernel generated, and copy the generated **.config** file to the corresponding path in the **config** repository. Then, the configuration takes effect.
>
> After the build is complete, the kernel is generated in the kernel directory in the **out** directory. Modify the **config** file for the target platform based on the kernel generated, and copy the generated **.config** file to the corresponding path of the platform in the **config** repository. Then, the configuration takes effect.