Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vflush: Print reclaim statistics #323

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions module/os/windows/spl/spl-time.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,12 @@
* origin. Hence its primary use is to specify intervals.
*/

static hrtime_t
zfs_abs_to_nano(uint64_t elapsed)
{
return (elapsed * KeQueryTimeIncrement() * 100);
}

/* Open Solaris lbolt is in hz */
uint64_t
zfs_lbolt(void)
{
uint64_t lbolt_hz;
LARGE_INTEGER ticks;
KeQueryTickCount(&ticks);
lbolt_hz = ticks.QuadPart * KeQueryTimeIncrement();
lbolt_hz = gethrtime() / 100;
lbolt_hz /= (10000000 / 119); // Solaris hz ?
return (lbolt_hz);
}
Expand All @@ -59,14 +51,16 @@ hrtime_t
gethrtime(void)
{
static LARGE_INTEGER start = { 0 };
static LARGE_INTEGER freq = { 0 };
LARGE_INTEGER now;
if (start.QuadPart == 0) {
KeQueryTickCount(&start);
start.QuadPart--;
start = KeQueryPerformanceCounter(&freq);
ASSERT(freq.QuadPart < NANOSEC);
ASSERT(freq.QuadPart > 0);
freq.QuadPart = NANOSEC / freq.QuadPart;
}
KeQueryTickCount(&now);
ASSERT((now.QuadPart != start.QuadPart));
return (zfs_abs_to_nano(now.QuadPart - start.QuadPart));
now = KeQueryPerformanceCounter(NULL);
return ((now.QuadPart - start.QuadPart) * freq.QuadPart);
}

/*
Expand All @@ -76,21 +70,21 @@ gethrtime(void)
int
random_get_bytes(uint8_t *ptr, uint32_t len)
{
LARGE_INTEGER TickCount;
LARGE_INTEGER PerfCounter;
ULONG r;
PULONG b;
int i;

KeQueryTickCount(&TickCount);
PerfCounter = KeQueryPerformanceCounter(NULL);

b = (PULONG) ptr;

for (i = 0; i < len / sizeof (ULONG); i++)
b[i] = RtlRandomEx(&TickCount.LowPart);
b[i] = RtlRandomEx(&PerfCounter.LowPart);

len &= (sizeof (ULONG) - 1);
if (len > 0) {
r = RtlRandomEx(&TickCount.LowPart);
r = RtlRandomEx(&PerfCounter.LowPart);
RtlCopyMemory(&b[i], &r, len);
}
return (0);
Expand Down
38 changes: 36 additions & 2 deletions module/os/windows/spl/spl-vnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1537,6 +1537,37 @@ mount_count_nodes(struct mount *mp, int flags)
return (count);
}

static void
print_reclaim_stats(boolean_t init, int reclaims)
{
static int last_reclaims = 0;
int reclaims_delta;
int reclaims_per_second;
static hrtime_t last_stats_time = 0;
hrtime_t last_stats_time_delta;

if (init) {
last_stats_time = gethrtime();
return;
}

if ((reclaims % 1000) != 0) {
return;
}

reclaims_delta = reclaims - last_reclaims;
last_stats_time_delta = gethrtime() - last_stats_time;

reclaims_per_second = (((int64_t)reclaims_delta) * NANOSEC) /
MAX(last_stats_time_delta, 1);

dprintf("%s: %d reclaims processed (%d/s).\n", __func__, reclaims,
reclaims_per_second);

last_reclaims = reclaims;
last_stats_time = gethrtime();
}


/*
* Let's try something new. If we are to vflush, lets do everything we can
Expand Down Expand Up @@ -1567,6 +1598,8 @@ vflush(struct mount *mp, struct vnode *skipvp, int flags)
mutex_enter(&vnode_all_list_lock);

filesanddirs:
print_reclaim_stats(B_TRUE, 0);

while (1) {
for (rvp = list_head(&vnode_all_list);
rvp;
Expand Down Expand Up @@ -1668,6 +1701,7 @@ vflush(struct mount *mp, struct vnode *skipvp, int flags)

if (!isbusy) {
reclaims++;
print_reclaim_stats(B_FALSE, reclaims);
break; // must restart loop if unlinked node
}
}
Expand All @@ -1684,8 +1718,8 @@ vflush(struct mount *mp, struct vnode *skipvp, int flags)

mutex_exit(&vnode_all_list_lock);

if (mp == NULL && reclaims > 0) {
dprintf("%s: %llu reclaims processed.\n", __func__, reclaims);
if (reclaims > 0) {
dprintf("%s: %d reclaims processed.\n", __func__, reclaims);
}


Expand Down
Loading