Skip to content

fadvise64

Intro

fadvise64 - system call that causes an advisory information about access pattern for a file region, in order to optimize file access.

Description

The fadvise64 system call advises the kernel about how a file will be accessed in the future, allowing the kernel to optimize its use of resources as appropriate. Given a file's descriptor fd, offset and len specify the size of the region offset that the advice applies to; the advice argument specifies the advice to be given.

Advice is advisory only, and need not be followed. The advice argument is a bitmask the can take any combination of the following values: - POSIX_FADV_NORMAL: No advice to give; the default assumption is that applications expect that read and write operations on the specified region will be performed in a reasonable amount of time. - POSIX_FADV_SEQUENTIAL: The applications expects that the access will be a sequential access pattern. - POSIX_FADV_RANDOM: The application expects that the access pattern will be a random access pattern. - POSIX_FADV_NOREUSE: The application expects that the access pattern will be a read-only pattern and that the data will not be reused in the near future.

Arguments

  • fd:int[K] - File descriptor for the file in question.
  • offset:off_t[K] - Offset into the file for the start of the region the advice applies to.
  • len:size_t[K] - Length of the region to which advice applies.
  • advice:int[K] - Advice given. May be a combination of the available flags in bitmask form.

Available Tags

  • K - Originated from kernel-space.

Hooks

sys_fadvise64

Type

Kprobes

Purpose

To record information about the usage of fadvise64 and the advice being given.

Example Use Case

An example use case for fadvise64 would be a database application using a large file for its data. The application could call fadvise64 with the advice POSIX_FADV_SEQUENTIAL to indicate to the kernel that the data access on this file is likely to occur in a sequential fashion. This allows the kernel to optimize its disk scheduling, resulting in improved disk performance.

Issues

When an application has not specified an access pattern to the kernel, it is not possible for the kernel to optimize its disk scheduling appropriately. As such, fadvise64 should not be used as a means of improving disk performance - it is only useful when an application can reliably determine an access pattern and communicate it to the kernel.

  • fsync - synchronizes a file's in-core state with storage device.
  • openat - opens a file from a given directory file descriptor.
  • madvise - system call advising the kernel about the address space access pattern.

This document was automatically generated by OpenAI and needs review. It might not be accurate and might contain errors. The authors of Tracee recommend that the user reads the "events.go" source file to understand the events and their arguments better.