Max size of one swap slice

Matthew Dillon dillon at apollo.backplane.com
Wed Aug 6 20:24:08 UTC 2008


:
:See
:
:http://www.freebsd.org/cgi/getmsg.cgi?fetch=540837+0+/usr/local/www/db/text/2008/freebsd-questions/20080706.freebsd-questions
:
:Kris

    Hmm.  I see an issue that FreeBSD could correct to reduce wired
    memory use by the swap system.

    Your sys/blist.h has this:

	typedef u_int32_t       u_daddr_t;      /* unsigned disk address */

    and your sys/types.h has this:

	typedef int64_t       daddr_t;      /* unsigned disk address */

    sys/blist.h really assumes a 32 bit daddr_t.  It's amazing the code
    even still works with daddr_t at 64 bits and u_daddr_t at 32 bits.

    Changing that whole mess in sys/blist.h to a different typedef name,
    say swblk_t (which is already defined to be 32 bits), and renaming
    u_daddr_t to u_swblk_t, plus also changing the swblock structure
    in vm/swap_pager.c to use a 32 bit array elements instead of 64 bit
    array elements will cut the size of struct swblock almost in half.

    There is no real need for swap block addressing > 32 bits.  32 bits
    gives you swap in the terrabyte range.

struct swblock {
        struct swblock  *swb_hnext;
        vm_object_t     swb_object;
        vm_pindex_t     swb_index;
        int             swb_count;
        daddr_t         swb_pages[SWAP_META_PAGES]; <<<<<<<<< this array
};

    Any arithmatic accessing the elements would also have to be vetted
    for any necessary promotions.

					-Matt
					Matthew Dillon 
					<dillon at backplane.com>


More information about the freebsd-stable mailing list