ktrace: provide ktrstat_error
This eliminates a branch from its consumers trading it for an extra call if ktrace is enabled for curthread. Given that this is almost never true, the tradeoff is worth it.
This commit is contained in:
parent
0017b2adac
commit
0a1427c5ab
@ -1445,16 +1445,14 @@ kern_fstat(struct thread *td, int fd, struct stat *sbp)
|
||||
error = fo_stat(fp, sbp, td->td_ucred, td);
|
||||
fdrop(fp, td);
|
||||
#ifdef __STAT_TIME_T_EXT
|
||||
if (error == 0) {
|
||||
sbp->st_atim_ext = 0;
|
||||
sbp->st_mtim_ext = 0;
|
||||
sbp->st_ctim_ext = 0;
|
||||
sbp->st_btim_ext = 0;
|
||||
}
|
||||
sbp->st_atim_ext = 0;
|
||||
sbp->st_mtim_ext = 0;
|
||||
sbp->st_ctim_ext = 0;
|
||||
sbp->st_btim_ext = 0;
|
||||
#endif
|
||||
#ifdef KTRACE
|
||||
if (error == 0 && KTRPOINT(td, KTR_STRUCT))
|
||||
ktrstat(sbp);
|
||||
if (KTRPOINT(td, KTR_STRUCT))
|
||||
ktrstat_error(sbp, error);
|
||||
#endif
|
||||
return (error);
|
||||
}
|
||||
|
@ -778,6 +778,14 @@ ktrstruct(const char *name, const void *data, size_t datalen)
|
||||
ktr_submitrequest(curthread, req);
|
||||
}
|
||||
|
||||
void
|
||||
ktrstruct_error(const char *name, const void *data, size_t datalen, int error)
|
||||
{
|
||||
|
||||
if (error == 0)
|
||||
ktrstruct(name, data, datalen);
|
||||
}
|
||||
|
||||
void
|
||||
ktrstructarray(const char *name, enum uio_seg seg, const void *data,
|
||||
int num_items, size_t struct_size)
|
||||
|
@ -2349,8 +2349,6 @@ kern_statat(struct thread *td, int flag, int fd, const char *path,
|
||||
}
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
vput(nd.ni_vp);
|
||||
if (error != 0)
|
||||
return (error);
|
||||
#ifdef __STAT_TIME_T_EXT
|
||||
sbp->st_atim_ext = 0;
|
||||
sbp->st_mtim_ext = 0;
|
||||
@ -2359,9 +2357,9 @@ kern_statat(struct thread *td, int flag, int fd, const char *path,
|
||||
#endif
|
||||
#ifdef KTRACE
|
||||
if (KTRPOINT(td, KTR_STRUCT))
|
||||
ktrstat(sbp);
|
||||
ktrstat_error(sbp, error);
|
||||
#endif
|
||||
return (0);
|
||||
return (error);
|
||||
}
|
||||
|
||||
#if defined(COMPAT_FREEBSD11)
|
||||
|
@ -280,6 +280,7 @@ void ktrprocexit(struct thread *);
|
||||
void ktrprocfork(struct proc *, struct proc *);
|
||||
void ktruserret(struct thread *);
|
||||
void ktrstruct(const char *, const void *, size_t);
|
||||
void ktrstruct_error(const char *, const void *, size_t, int);
|
||||
void ktrstructarray(const char *, enum uio_seg, const void *, int, size_t);
|
||||
void ktrcapfail(enum ktr_cap_fail_type, const cap_rights_t *,
|
||||
const cap_rights_t *);
|
||||
@ -291,6 +292,8 @@ void ktrcapfail(enum ktr_cap_fail_type, const cap_rights_t *,
|
||||
ktrstruct("sockaddr", (s), ((struct sockaddr *)(s))->sa_len)
|
||||
#define ktrstat(s) \
|
||||
ktrstruct("stat", (s), sizeof(struct stat))
|
||||
#define ktrstat_error(s, error) \
|
||||
ktrstruct_error("stat", (s), sizeof(struct stat), error)
|
||||
extern u_int ktr_geniosize;
|
||||
#else
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user