Project

General

Profile

Bug #5514

hat_unload_callback passes the wrong length to segvn_hat_unload_callback

Added by Matthew Ahrens almost 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
Normal
Category:
kernel
Start date:
2015-01-08
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage

Description

hat_unload_callback() is supposed to call the specified callback on each range that is unloaded. The only consumer of this is segvn_unmap(), which specifies the segvn_hat_unload_callback().

However, the length passed to the callback is always wrong. It happens to be the number of pages, rather than the number of bytes, but this is also an accident. It's "lucky" that this is less than the correct size, so that segvn_hat_unload_callback() unloads less pages than it should, which is handled properly. If pagesize was different, we could pass a much larger length than we should, causing it to unload too many pages, breaking everything.

The problem is that handle_ranges() computes the length as "rng_cnt << LEVEL_SIZE(rng_level)". LEVEL_SIZE() gives the size in bytes, so we are typically shifting by 4096, with undefined results.

The fix is to shift by LEVEL_SHIFT().

History

#1

Updated by Electric Monk almost 5 years ago

  • % Done changed from 0 to 100
  • Status changed from New to Closed

git commit a6a74e0e62d62ff750cd4b790be5eacc99c3bb8c

commit  a6a74e0e62d62ff750cd4b790be5eacc99c3bb8c
Author: Matthew Ahrens <mahrens@delphix.com>
Date:   2015-01-16T02:21:04.000Z

    5498 kmem_reap does one xcall per page
    5514 hat_unload_callback passes the wrong length to segvn_hat_unload_callback
    Reviewed by: Adam Leventhal <ahl@delphix.com>
    Reviewed by: Dan Kimmel <dan.kimmel@delphix.com>
    Reviewed by: George Wilson <george.wilson@delphix.com>
    Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
    Reviewed by: Paul Dagnelie <paul.dagnelie@delphix.com>
    Reviewed by: Robert Mustacchi <rm@joyent.com>
    Approved by: Richard Lowe <richlowe@richlowe.net>

Also available in: Atom PDF