Re: Alignment of disk-I/O from userland.
From: Poul-Henning Kamp (phk_at_phk.freebsd.dk)
Date: 10/07/03
- Previous message: Scott Long: "Re: Alignment of disk-I/O from userland."
- In reply to: Scott Long: "Re: Alignment of disk-I/O from userland."
- Next in thread: Don Lewis: "Re: Alignment of disk-I/O from userland."
- Reply: Don Lewis: "Re: Alignment of disk-I/O from userland."
- Reply: Sam Leffler: "Re: Alignment of disk-I/O from userland."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: Scott Long <scottl@freebsd.org> Date: Tue, 07 Oct 2003 01:11:11 +0200
In message <20031006163218.L55190@pooker.samsco.home>, Scott Long writes:
>We already
>have the busdma interface whose sole purpose is to take system
>buffers and prepare them for transfer to/from hardware [...]
I certainly do agree that _if_ we do want to do copy/align busdma would
be a good place for it.
>As for returning an error code for a buffer that we (arbitrarily) believe
>to be too big to align, [...]
I have never advocated returning an error based on "alignment and size",
only based on alignment alone.
But I also just realized a complication I had not thought of earlier,
and which may modify our thinking further: This is an issue for
all physread()/physwrite() drivers, not just disks.
In other words, if I want to write to 1MB blocks to a SCSI tape,
and I don't align my in memory buffer sufficiently for the hardware,
busdma would have to allocate 1MB of memory (it may _possibly_ be
able to do so as disjunct pages rather than consequtively) and copy
the entire request over.
For disks we can chop the request at sector boundaries or multiple
thereoff and deal with it that way, but we don't have that option
for scsi_sa or even scsi_pt devices.
Currently we impose a 128k upper limit on I/O requests, but we have
already more or less agreed that needs to grow into the 4-16MB range
soon.
The more I think about it, there more arguments I find for retaining
the status quo of requiring userland to do proper alignment (but
with better error-checking).
Particularly since the only unaligned case I know of yet, newfs(8),
is by trivial accident rather than need or intent.
The question of how to communicate the alignment required to
userland has been raised. I propose this answer:
Suffient alignment can be obtained by any one of these methods:
1. Allocate your buffer with malloc(3).
2. Align it to the request size.
3. Align it to a page.
(The first is somewhat dependent on the behaviour of phkmalloc, and
can be removed, but it offers a nice clean shortcut for most
programmers.)
-- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. _______________________________________________ freebsd-arch@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-arch To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"
- Previous message: Scott Long: "Re: Alignment of disk-I/O from userland."
- In reply to: Scott Long: "Re: Alignment of disk-I/O from userland."
- Next in thread: Don Lewis: "Re: Alignment of disk-I/O from userland."
- Reply: Don Lewis: "Re: Alignment of disk-I/O from userland."
- Reply: Sam Leffler: "Re: Alignment of disk-I/O from userland."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|