Changeset View
Standalone View
sys/sys/file.h
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | |||||
struct file; | struct file; | ||||
struct filecaps; | struct filecaps; | ||||
struct kaiocb; | struct kaiocb; | ||||
struct kinfo_file; | struct kinfo_file; | ||||
struct ucred; | struct ucred; | ||||
#define FOF_OFFSET 0x01 /* Use the offset in uio argument */ | #define FOF_OFFSET 0x01 /* Use the offset in uio argument */ | ||||
#define FOF_NOLOCK 0x02 /* Do not take FOFFSET_LOCK */ | #define FOF_NOLOCK 0x02 /* Do not take FOFFSET_LOCK */ | ||||
#define FOF_NEXTOFF 0x04 /* Also update f_nextoff */ | #define FOF_NEXTOFF_R 0x04 /* Also update f_nextoff[UIO_READ] */ | ||||
#define FOF_NEXTOFF_W 0x08 /* Also update f_nextoff[UIO_WRITE] */ | |||||
#define FOF_NOUPDATE 0x10 /* Do not update f_offset */ | #define FOF_NOUPDATE 0x10 /* Do not update f_offset */ | ||||
off_t foffset_lock(struct file *fp, int flags); | off_t foffset_lock(struct file *fp, int flags); | ||||
void foffset_lock_uio(struct file *fp, struct uio *uio, int flags); | void foffset_lock_uio(struct file *fp, struct uio *uio, int flags); | ||||
void foffset_unlock(struct file *fp, off_t val, int flags); | void foffset_unlock(struct file *fp, off_t val, int flags); | ||||
void foffset_unlock_uio(struct file *fp, struct uio *uio, int flags); | void foffset_unlock_uio(struct file *fp, struct uio *uio, int flags); | ||||
static inline off_t | static inline off_t | ||||
foffset_get(struct file *fp) | foffset_get(struct file *fp) | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | struct file { | ||||
short f_type; /* descriptor type */ | short f_type; /* descriptor type */ | ||||
short f_vnread_flags; /* (f) Sleep lock for f_offset */ | short f_vnread_flags; /* (f) Sleep lock for f_offset */ | ||||
volatile u_int f_flag; /* see fcntl.h */ | volatile u_int f_flag; /* see fcntl.h */ | ||||
volatile u_int f_count; /* reference count */ | volatile u_int f_count; /* reference count */ | ||||
/* | /* | ||||
* DTYPE_VNODE specific fields. | * DTYPE_VNODE specific fields. | ||||
*/ | */ | ||||
union { | union { | ||||
int16_t f_seqcount; /* (a) Count of sequential accesses. */ | int16_t f_seqcount[2]; /* (a) Count of seq. reads and writes. */ | ||||
int f_pipegen; | int f_pipegen; | ||||
}; | }; | ||||
off_t f_nextoff; /* next expected read/write offset. */ | off_t f_nextoff[2]; /* next expected read/write offset. */ | ||||
kib: I do not like this, of course, It gives +8 bytes to struct file.
Could you change the type of… | |||||
Not Done Inline ActionsThe problem with the struct is that it is past 64 bytes already and there is no way to shrink it. This has a side effect where updates to the reference counter can result in false sharing. Thus I think the way to go is to to let the struct grow and if the NOFREE status becomes a problem that status can be revisited with SMR. mjg: The problem with the struct is that it is past 64 bytes already and there is no way to shrink… | |||||
Not Done Inline ActionsThe problem with the struct is the memory usage. Patch adds +8 bytes. which even on my small desktop with kern.maxfiles=1043454 equals to potentially consuming 8MB of kernel memory. NOFREE also adds to the whole picture, of course. kib: The problem with the struct is the memory usage. Patch adds +8 bytes. which even on my small… | |||||
Not Done Inline ActionsWell that's true but it would also be a small fraction of total memory usage given all these object will be mostly pointing to distinct other objects of significantly bigger size. Also note there is an older review which points out that the struct can be shortened in size 8 bytes by removing the unused f_label field. This can be resurrected to get this in without further complications. mjg: Well that's true but it would also be a small fraction of total memory usage given all these… | |||||
Not Done Inline ActionsI am fine with removing f_label as an intermediate measure. kib: I am fine with removing f_label as an intermediate measure. | |||||
Not Done Inline Actionsf_nextoff can be arbitrarily different from f_offset, for example consider the case of a >2GB file which is being read and written exclusively with pread/pwrite, andrew_tao173.riddles.org.uk: f_nextoff can be arbitrarily different from f_offset, for example consider the case of a >2GB… | |||||
Not Done Inline ActionsOf course it can be, then the seq heuristic would (should) fail. kib: Of course it can be, then the seq heuristic would (should) fail. | |||||
Not Done Inline Actions"should" fail? proper sequential heuristics for the case when the application is using pread exclusively are essential. andrew_tao173.riddles.org.uk: "should" fail? proper sequential heuristics for the case when the application is using pread… | |||||
union { | union { | ||||
struct cdev_privdata *fvn_cdevpriv; | struct cdev_privdata *fvn_cdevpriv; | ||||
/* (d) Private data for the cdev. */ | /* (d) Private data for the cdev. */ | ||||
struct fadvise_info *fvn_advice; | struct fadvise_info *fvn_advice; | ||||
} f_vnun; | } f_vnun; | ||||
/* | /* | ||||
* DFLAG_SEEKABLE specific fields | * DFLAG_SEEKABLE specific fields | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 262 Lines • Show Last 20 Lines |
I do not like this, of course, It gives +8 bytes to struct file.
Could you change the type of f_nextoff to int32 and only store the addend to f_offset, for instance ?