Page MenuHomeFreeBSD

Halve the memory allocated by the blist allocator that is used for managing swap space
ClosedPublic

Authored by alc on Jun 2 2017, 4:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 31, 8:05 PM
Unknown Object (File)
Dec 5 2024, 3:04 AM
Unknown Object (File)
Nov 22 2024, 11:15 PM
Unknown Object (File)
Oct 23 2024, 4:05 AM
Unknown Object (File)
Oct 7 2024, 1:23 AM
Unknown Object (File)
Sep 30 2024, 11:33 PM
Unknown Object (File)
Sep 22 2024, 3:42 PM
Unknown Object (File)
Sep 14 2024, 6:58 PM
Subscribers

Details

Summary

At the heart of the blist allocator is a union:

typedef struct blmeta {
        union {
            daddr_t     bmu_avail;      /* space available under us     */
            u_daddr_t   bmu_bitmap;     /* bitmap if we are a leaf      */
        } u;
        daddr_t         bm_bighint;     /* biggest contiguous block hint*/
} blmeta_t;

At some point in the distant past, daddr_t became a 64-bit integer, but u_daddr_t, which is defined locally by the blist allocator, was not extended from 32 to 64 bits. Consequently, the blist allocator started allocating twice as much memory to manage the same amount of swap space. This change updates the size of u_daddr_t to be 64 bits. This also requires a couple casts to be introduced where a 32-bit integer constant is being shifted to create a bit mask of type u_daddr_t.

Test Plan

I've tested this change locally on an amd64 machine. I'll ask Peter to stress test this change on both an amd64 and i386 machine.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib added inline comments.
sys/blist.h
59 โ†—(On Diff #29147)

Just curious, why do you use protected type name instead of uint64_t ? I suppose that it should be usable everywhere, because u_int32_t worked.

This revision is now accepted and ready to land.Jun 2 2017, 6:20 PM
sys/blist.h
59 โ†—(On Diff #29147)

I had no compelling reason. I'll change it tonight when I get home.

It looks like the comment above the MAX_PAGEOUT_CLUSTER definition should be updated too.

alc edited edge metadata.
This revision now requires review to proceed.Jun 3 2017, 4:27 PM

Peter, could you please test this patch on both amd64 and i386 under swap intensive workloads.

In D11028#228674, @alc wrote:

Peter, could you please test this patch on both amd64 and i386 under swap intensive workloads.

Sure. Glad to.

This revision is now accepted and ready to land.Jun 3 2017, 6:28 PM

I think that the old definition of u_daddr_t is responsible for this snippet:

    /*                                                                                          
     * If we go beyond this, we get overflows in the radix                                      
     * tree bitmap code.                                                                        
     */
    mblocks = 0x40000000 / BLIST_META_RADIX;
    if (nblks > mblocks) {
            printf(
"WARNING: reducing swap size to maximum of %luMB per unit\n",
                mblocks / 1024 / 1024 * PAGE_SIZE);
            nblks = mblocks;
    }

Specifically, the effect that the old definition has on this definition:

#define SWAPBLK_MASK    ((daddr_t)((u_daddr_t)-1 >> 1))         /* mask */

I ran all stress2 test with this patch. Half on i386 and the other half on amd64. I ran a -j 25 buildworld with 2 GB RAM on amd64.
No problems seen.

This revision was automatically updated to reflect the committed changes.