public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: William Lee Irwin III <wli@holomorphy.com>
To: Bill Davidsen <davidsen@tmr.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Swap maximum size documented ?
Date: Wed, 1 Jun 2005 13:08:55 -0700	[thread overview]
Message-ID: <20050601200855.GQ20782@holomorphy.com> (raw)
In-Reply-To: <429E10B9.601@tmr.com>

On Wed, Jun 01, 2005 at 03:47:05PM -0400, Bill Davidsen wrote:
>> mmap() is limited only by file offsets, which are fully 32-bit on
>> 32-bit systems. remap_file_pages() is limited by PTE_FILE_MAX_BITS,
>> which is fully 32-bit with CONFIG_HIGHMEM64G=y on i386 but only 29 bit
>> without it on i386. In general checking for PTE_FILE_MAX_BITS on the
>> relevant architecture should answer your question for remap_file_pages(),
>> and BITS_PER_LONG for mmap(). The swap limits for other architectures
>> will also differ and you generally have to look at the swp_entry/pte
>> encoding/decoding macros to decipher what the precise limits are
>> (though a quick hacky C program can help discover them for you).
>> Generally you get the filesizes by PAGE_SIZE << X_FILE_OFFSET_BITS.

The hacky C program. Note that some fiddling with compiler flags is
needed to get it to compile at all, and you probably need to have
done make oldconfig or similar to prep the kernel tree too. The answer
necessarily varies with your .config and it won't work cross-arch
except in the 32/64 -bit variant case (in which case it must be
compiled as the same kind of app [32/64] the kernel is expected to be).

The expressions for the swap limits were taken from sys_swapon().

This should remove all doubt, if any remain.


#include <linux/config.h>
#include <linux/swap.h>
#include <asm/pgtable.h>
#include <linux/swapops.h>

int printf(const char *, ...);

int main(void)
{
	unsigned long long type, offset;

	type = swp_type(pte_to_swp_entry(swp_entry_to_pte(swp_entry(~0UL,0))));
	offset = swp_offset(pte_to_swp_entry(swp_entry_to_pte(swp_entry(0,~0UL)))) - 1;
	offset = (offset << PAGE_SHIFT) + ~PAGE_MASK;

	printf("max swapfiles = %Lu files\n", type);
	printf("max swapsize = %Lu B\n", offset);
	return 0;
}

  reply	other threads:[~2005-06-01 20:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-01 12:25 Swap maximum size documented ? david.balazic
2005-06-01 12:34 ` William Lee Irwin III
2005-06-01 12:40 ` Jakob Oestergaard
2005-06-01 12:58   ` Arjan van de Ven
2005-06-01 13:02     ` David Balažic
2005-06-01 13:40       ` William Lee Irwin III
2005-06-01 19:10         ` Bill Davidsen
2005-06-01 19:29           ` William Lee Irwin III
2005-06-01 19:47             ` Bill Davidsen
2005-06-01 20:08               ` William Lee Irwin III [this message]
2005-06-01 22:15               ` cutaway
2005-06-01 23:57                 ` Bill Davidsen
2005-06-01 20:43           ` Lennart Sorensen
2005-06-01 20:54             ` William Lee Irwin III
2005-06-01 21:05               ` Lennart Sorensen
2005-06-01 23:49                 ` Bill Davidsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050601200855.GQ20782@holomorphy.com \
    --to=wli@holomorphy.com \
    --cc=davidsen@tmr.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox