From nobody Tue Aug 18 15:21:56 2026 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4hPYN86HPfz6pLyM for ; Tue, 18 Aug 2026 15:22:16 +0000 (UTC) (envelope-from darthferrett@gmail.com) Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hPYN73sX1z3m92 for ; Tue, 18 Aug 2026 15:22:15 +0000 (UTC) (envelope-from darthferrett@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20251104 header.b=kVWtDo8c; spf=pass (mx1.freebsd.org: domain of darthferrett@gmail.com designates 2607:f8b0:4864:20::735 as permitted sender) smtp.mailfrom=darthferrett@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-qk1-x735.google.com with SMTP id af79cd13be357-930c0f9c1b1so269226785a.1 for ; Tue, 18 Aug 2026 08:22:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787066530; x=1787671330; darn=freebsd.org; h=references:to:cc:in-reply-to:date:subject:mime-version:content-type :message-id:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=bPUUFUUhRKIqxvUs+c7FWb0pNUCy3ABmWaZDpMpSU5k=; b=kVWtDo8cRhk9aUeb60ZhXWkou2OcOoeSr97xSf1np7na+Oghui6oKGMqZ9/IhqtbKz m8NvxNqm5wS5cchXBCrJfOVKCfiQ7qwqpyz+YLA9tjzw+T/sa5GxsK9MfOsbDs7Apdoq HyJpWqQCmLlMahPzuthxteT6/GdUSAUkBcSZltk1q/biP1j5gJL+ZvizjACiRsU5Pn20 +lc4BrmDvmuCJeX4CYk1dReNaL8GiCAr8/rYtVAQ3U5nFIGrazcy3sM9JQoGtPdm6oL4 iTjaE4pm1U61OFbPiWKmbCP4s93tRN/YVxAR6GW8ojVFQZ1sVxVY6OY32yTunSA/VUVO ukiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787066530; x=1787671330; h=references:to:cc:in-reply-to:date:subject:mime-version:content-type :message-id:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=bPUUFUUhRKIqxvUs+c7FWb0pNUCy3ABmWaZDpMpSU5k=; b=Z4TqKwt5LOu5aYba/EbAfn7DXGMwJwJ37ZppefHA///GyZESYYeokhAm994AmONU5/ NWLZfO/E0FcAF8AGlMn6Eneg/IhHVb3IRGnPlyY76Q+g+x5TuoUOPuUvWIFX5NCbxcAN bPLGMI1qxknj5Na4z9x7I+DBhAEs1dcuabLuuWN41qevwMoak+cs1/hS/gXgYGdJl5jN CNGkVsArRAH/ykNXCbC0b1TjeAJsJhhP59FUVWcX+QUbHBVa4lD3KIvj5mtjz2nksGa8 2qOakqDFcv7J3r1FR2UWaN4rrgFVbavZ89dBtFxyR2q9XHs2rdoOE3txzB6A35mQemDR WnPQ== X-Forwarded-Encrypted: i=1; AHgh+RrqV2jpA/v1E89nlLFa9czT8UrhuYBmxx07+gBFNJ9LLPGqX24fG7YeX4gzSjlQsLMNBsfOwSx/3kiFUz2JiN4=@freebsd.org X-Gm-Message-State: AOJu0YwhQdVp+CgWjSw+WGIhOVnLggAxkYoPOkkp8XV+Mq4dmS4biMjQ GSxo1hgAAnm1xw1+dPA2b+3lwTuppZY6c/4jLS0l3jUmANXOMQccLX3KdPszuQ== X-Gm-Gg: AR+sD12al778ZEZtdACKusoIwUTGVt/dnJ78ZZWoJtesN9Bxo/ODQkSkOYXiC527S6s oHquoVBtZVGhKpO1iiDC7RnJ1hsXzkmHPYyeZdbsUY28c+Ukej0KoB2i0qKA+7HN7E4oQAgPhQI MxA/9Jn51be4kh02u4xpujc6dt3oRdsP9T9IvBGDYcQlmqW537//AzDmh/y76ltb8C+koFWiz+X QgQNNPp60vdvXWwHqe37cx72RPRxj8Ntoj1sTAh0jLW240QbpB3Vw3A3H+M2EC0W9fLTKi0JDhK 2iTKU+4c3R2j42rMCN+1B/odEKn9mworR1iD4DTokKIDnvFT0m56VU4R/ZFzfQkWZK593n38zAr 9Gs+ryduyqmnPveR/yTgAnhgIJiY/pJDaW2jLJhforp4l4HmWeARhL9zE6ZgP5O2g+PcB2Xu9Nq JKYDDcSoTue0SGtXhVzO5jIEtrzV8hJDBlpCZ0OKXmeVPxoUCczqLQnOPJnvBYSI/adCq0dLSD+ A== X-Received: by 2002:a05:620a:2906:b0:91c:c20b:a135 with SMTP id af79cd13be357-93704bc6e9dmr830535085a.40.1787066529217; Tue, 18 Aug 2026 08:22:09 -0700 (PDT) Received: from chestnut_handy.imbrinet.net ([70.92.149.246]) by smtp.gmail.com with ESMTPSA id af79cd13be357-937010c512dsm353222185a.3.2026.08.18.08.22.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2026 08:22:08 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by chestnut_handy.imbrinet.net (Postfix) with ESMTP id AEC6C1D5804; Tue, 18 Aug 2026 10:22:07 -0500 (CDT) X-Virus-Scanned: amavis at imbrinet.net Received: from chestnut_handy.imbrinet.net ([127.0.0.1]) by localhost (chestnut_handy.imbrinet.net [127.0.0.1]) (amavis, port 10024) with ESMTP id wBxCp3-Ei7is; Tue, 18 Aug 2026 10:22:07 -0500 (CDT) Received: from smtpclient.apple (gateway [192.168.1.1]) by chestnut_handy.imbrinet.net (Postfix) with ESMTPSA id 674D41D5803; Tue, 18 Aug 2026 10:22:07 -0500 (CDT) From: Joshua Armstrong Message-Id: <2C1AFC77-C3A6-4B21-83D1-40E7E6B605E8@gmail.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_FFB7D75F-B9CB-4570-A770-668F41328C76" List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6.1.21\)) Subject: Re: Swap partition priority Date: Tue, 18 Aug 2026 10:21:56 -0500 In-Reply-To: Cc: =?utf-8?Q?St=C3=A9phane_Rochoy?= , Andrea Venturoli , freebsd-hackers@freebsd.org To: Miroslav Lachman <000.fbsd@quip.cz> References: <8918ee68-de5d-4a63-b960-e5d70a9cda3f@netfence.it> <875x17uau6.fsf@stormshield.eu> <389ed2cf-94ee-4804-bed9-439a9f0c8643@quip.cz> X-Mailer: Apple Mail (2.3731.700.6.1.21) X-Spamd-Result: default: False [-1.60 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_SPAM_SHORT(0.90)[0.902]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; MV_CASE(0.50)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20251104]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4864::/56]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_TLS_LAST(0.00)[]; TO_DN_SOME(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; ARC_NA(0.00)[]; RECEIVED_HELO_LOCALHOST(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; FROM_HAS_DN(0.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCPT_COUNT_THREE(0.00)[4]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; MID_RHS_MATCH_FROM(0.00)[]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org]; FREEMAIL_ENVFROM(0.00)[gmail.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::735:from] X-Rspamd-Queue-Id: 4hPYN73sX1z3m92 X-Spamd-Bar: - --Apple-Mail=_FFB7D75F-B9CB-4570-A770-668F41328C76 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Short answer, yes - interleaving is hardcoded and the swapon(2) syscall = only accepts the device node name (or file name). Here=E2=80=99s the doc = header comment for the allocation code in sys/vm/swap_pager.c: 915 /* 916 * SWP_PAGER_GETSWAPSPACE() - allocate raw swap space 917 * 918 * Allocate swap for up to the requested number of pages. = The 919 * starting swap block number (a page index) is returned or 920 * SWAPBLK_NONE if the allocation failed. 921 * 922 * Also has the side effect of advising that somebody made = a mistake 923 * when they configured swap and didn't configure enough. 924 * 925 * This routine may not sleep. 926 * 927 * We allocate in round-robin fashion from the configured = devices. 928 */ However, the suggestion to use a concatenated GEOM should work great = because that=E2=80=99s a single device according to the swap and the = GEOM allocator is (should be) entirely transparent to the swap strategy: Relevant snippet from swapgeom_strategy: 3212 bp->b_caller1 =3D bio; 3213 bio->bio_caller1 =3D sp; 3214 bio->bio_caller2 =3D bp; 3215 bio->bio_cmd =3D bp->b_iocmd; 3216 bio->bio_offset =3D (bp->b_blkno - sp->sw_first) * = PAGE_SIZE; 3217 bio->bio_length =3D bp->b_bcount; 3218 bio->bio_done =3D swapgeom_done; 3219 bio->bio_flags |=3D BIO_SWAP; 3220 if (!buf_mapped(bp)) { 3221 bio->bio_ma =3D bp->b_pages; 3222 bio->bio_data =3D unmapped_buf; 3223 bio->bio_ma_offset =3D (vm_offset_t)bp->b_offset = & PAGE_MASK; 3224 bio->bio_ma_n =3D bp->b_npages; 3225 bio->bio_flags |=3D BIO_UNMAPPED; 3226 } else { 3227 bio->bio_data =3D bp->b_data; 3228 bio->bio_ma =3D NULL; 3229 } 3230 g_io_request(bio, cp); 3231 return; > On Aug 18, 2026, at 9:00 AM, Joshua Armstrong = wrote: >=20 > I=E2=80=99ll throw my hat into this ring. >=20 > As soon as I=E2=80=99m finished with my meeting, I=E2=80=99ll check = the swap management / virtual memory code to see if interleaving is = hardcoded or not. I believe the current (and long-standing, according to = my ancient copy of the Unix System Administration Handbook) behavior is = to interleave swap writes between configured devices for performance. >=20 > I agree, however, that having a priority system would make more sense = in today=E2=80=99s world. I sometimes end up creating a temporary zvol = and using that as emergency extra swap if I=E2=80=99m building world, = but I would assume this has a performance penalty (though perhaps not = massive) versus swap partitions on bare disks. >=20 > -Joshua >=20 >> On Aug 18, 2026, at 3:48 AM, Miroslav Lachman <000.fbsd@quip.cz> = wrote: >>=20 >> On 18/08/2026 09:49, St=C3=A9phane Rochoy wrote: >>> Andrea Venturoli writes: >>>> Is it possible to set swap partition priority? >>>> According to swapon(8), the answer is no, but I wonder if the man = page >>>> might be outdated, if patches are available, etc... >>>>=20 >>>> The reason is I have SSDs and HDDs in the same system: I normally = use >>>> swap on SSDs (for speed obviously), but sometimes the amount is not = enough. >>>> So I'm ponderind adding swap on HDDS too, but this would slow down >>>> everyrting unless it's really used as last resort. >>> Hello, >>> Long ago I came accross a setup were the swap device was a GEOM = mirror >>> (see gmirror(8)). AFAIK it was working except for vmcores: the = kernel >>> was always using the first device which required to help savecore(8) = a >>> bit. >>> So maybe there's some GEOM class matching your needs. >> There is geom_concat - see man gconcat. It may be possible to use it = for swap (never tried it). >>=20 >> Best regards >> Miroslav Lachman >>=20 >=20 --Apple-Mail=_FFB7D75F-B9CB-4570-A770-668F41328C76 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Short answer, = yes - interleaving is hardcoded and the swapon(2) syscall only accepts = the device node name (or file name). Here=E2=80=99s the doc header = comment for the allocation code in = sys/vm/swap_pager.c:

    915 /*

    = 916  * SWP_PAGER_GETSWAPSPACE() -   allocate raw swap = space

    = 917  *

    = 918  *      Allocate swap for up to the requested = number of pages.  The

    = 919  *      starting swap block number (a page = index) is returned or

    = 920  *      SWAPBLK_NONE if the allocation = failed.

    = 921  *

    = 922  *      Also has the side effect of advising = that somebody made a mistake

    = 923  *      when they configured swap and didn't = configure enough.

    = 924  *

    = 925  *      This routine may not sleep.

    = 926  *

    = 927  *      We allocate in round-robin fashion from = the configured devices.

    = 928  */


However, the suggestion to use a concatenated GEOM = should work great because that=E2=80=99s a single device according to = the swap and the GEOM allocator is (should be) entirely transparent to = the swap strategy:


Relevant snippet from = swapgeom_strategy:


   3212         = bp->b_caller1 =3D bio;

   3213         = bio->bio_caller1 =3D sp;

   3214         = bio->bio_caller2 =3D bp;

   3215         = bio->bio_cmd =3D bp->b_iocmd;

   3216         = bio->bio_offset =3D (bp->b_blkno - sp->sw_first) * = PAGE_SIZE;

   3217         = bio->bio_length =3D bp->b_bcount;

   3218         = bio->bio_done =3D swapgeom_done;

   3219         = bio->bio_flags |=3D BIO_SWAP;

   3220         if = (!buf_mapped(bp)) {

   3221         =         bio->bio_ma =3D = bp->b_pages;

   3222         =         bio->bio_data =3D = unmapped_buf;

   3223         =         bio->bio_ma_offset =3D = (vm_offset_t)bp->b_offset & PAGE_MASK;

   3224 =                 bio->bio_ma_n = =3D bp->b_npages;

   3225         =         bio->bio_flags |=3D = BIO_UNMAPPED;

   3226         } = else {

   3227         =         bio->bio_data =3D = bp->b_data;

   3228         =         bio->bio_ma =3D NULL;

   3229 =         }

   3230         = g_io_request(bio, cp);

   3231         = return;



On Aug 18, 2026, at 9:00 AM, Joshua Armstrong = <darthferrett@gmail.com> wrote:

I=E2=80=99ll throw my hat = into this ring.

As soon as I=E2=80=99m finished with my meeting, = I=E2=80=99ll check the swap management / virtual memory code to see if = interleaving is hardcoded or not. I believe the current (and = long-standing, according to my ancient copy of the Unix System = Administration Handbook) behavior is to interleave swap writes between = configured devices for performance.

I agree, however, that having = a priority system would make more sense in today=E2=80=99s world. I = sometimes end up creating a temporary zvol and using that as emergency = extra swap if I=E2=80=99m building world, but I would assume this has a = performance penalty (though perhaps not massive) versus swap partitions = on bare disks.

-Joshua

On Aug = 18, 2026, at 3:48 AM, Miroslav Lachman <000.fbsd@quip.cz> = wrote:

On 18/08/2026 09:49, St=C3=A9phane Rochoy = wrote:
Andrea Venturoli = <ml@netfence.it> writes:
Is it = possible to set swap partition priority?
According to swapon(8), the = answer is no, but I wonder if the man page
might be outdated, if = patches are available, etc...

The reason is I have SSDs and HDDs = in the same system: I normally use
swap on SSDs (for speed = obviously), but sometimes the amount is not enough.
So I'm ponderind = adding swap on HDDS too, but this would slow down
everyrting unless = it's really used as last resort.
Hello,
Long ago I = came accross a setup were the swap device was a GEOM mirror
(see = gmirror(8)). AFAIK it was working except for vmcores: the kernel
was = always using the first device which required to help savecore(8) = a
bit.
So maybe there's some GEOM class matching your = needs.
There is geom_concat - see man gconcat. It may be = possible to use it for swap (never tried it).

Best = regards
Miroslav = Lachman



<= /body>= --Apple-Mail=_FFB7D75F-B9CB-4570-A770-668F41328C76--