[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 5/5] rumpdisk: Fault-in the memory pages
From: |
Samuel Thibault |
Subject: |
Re: [PATCH 5/5] rumpdisk: Fault-in the memory pages |
Date: |
Mon, 27 Dec 2021 15:51:05 +0100 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
Damien Zammit, le dim. 26 déc. 2021 22:38:57 +1100, a ecrit:
> This ensures memory pages are allocated before written to.
Applied, thanks!
> ---
> rumpdisk/block-rump.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/rumpdisk/block-rump.c b/rumpdisk/block-rump.c
> index 7a4a167e..fe97bf85 100644
> --- a/rumpdisk/block-rump.c
> +++ b/rumpdisk/block-rump.c
> @@ -284,10 +284,18 @@ rumpdisk_device_write (void *d, mach_port_t reply_port,
> {
> struct block_data *bd = d;
> ssize_t written;
> + volatile uint8_t dummy_read;
> + int pagesize = sysconf (_SC_PAGE_SIZE);
> + int npages = (count + pagesize - 1) / pagesize;
> + int i;
>
> if ((bd->mode & D_WRITE) == 0)
> return D_INVALID_OPERATION;
>
> + /* Fault-in the memory pages by reading a single byte of each */
> + for (i = 0; i < npages; i++)
> + dummy_read = ((volatile uint8_t *)data)[i * pagesize];
> +
> written = rump_sys_pwrite (bd->rump_fd, (const void *)data, (size_t)count,
> (off_t)bn * bd->block_size);
> vm_deallocate (mach_task_self (), (vm_address_t) data, count);
>
> @@ -313,6 +321,7 @@ rumpdisk_device_read (void *d, mach_port_t reply_port,
> vm_address_t buf;
> int pagesize = sysconf (_SC_PAGE_SIZE);
> int npages = (count + pagesize - 1) / pagesize;
> + int i;
> ssize_t err;
> kern_return_t ret;
>
> @@ -327,8 +336,9 @@ rumpdisk_device_read (void *d, mach_port_t reply_port,
> if (ret != KERN_SUCCESS)
> return ENOMEM;
>
> - /* Ensure physical allocation. */
> - memset (buf, 0, npages * pagesize);
> + /* Ensure physical allocation by writing a single byte of each */
> + for (i = 0; i < npages; i++)
> + ((uint8_t *)buf)[i * pagesize] = 0;
>
> err = rump_sys_pread (bd->rump_fd, (void *)buf, (size_t)count, (off_t)bn *
> bd->block_size);
> if (err < 0)
> --
> 2.33.1
>
>
--
Samuel
I am the "ILOVEGNU" signature virus. Just copy me to your signature.
This email was infected under the terms of the GNU General Public License.
- [PATCH 0/5] hurd: Patches for new librump, Damien Zammit, 2021/12/26
- [PATCH 1/5] rumpdisk: define _STANDALONE to avoid register_t, Damien Zammit, 2021/12/26
- [PATCH 2/5] rumpdisk: Link with rumpvfs_nofifofs if present, Damien Zammit, 2021/12/26
- [PATCH 4/5] pci-arbiter,rumpdisk: Lock all memory for swapping, Damien Zammit, 2021/12/26
- [PATCH 5/5] rumpdisk: Fault-in the memory pages, Damien Zammit, 2021/12/26
- Re: [PATCH 5/5] rumpdisk: Fault-in the memory pages,
Samuel Thibault <=
- [PATCH 3/5] rumpdisk: Use raw uncached character device rwdXd, Damien Zammit, 2021/12/26