Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 154814 Details for
Bug 211335
Missing page_cache_release() in do_direct_IO() causes memory leak.
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
test program
direct_io_test.c (text/plain), 1.95 KB, created by
Radovan Augustin
on 2007-05-16 12:54:39 UTC
(
hide
)
Description:
test program
Filename:
MIME Type:
Creator:
Radovan Augustin
Created:
2007-05-16 12:54:39 UTC
Size:
1.95 KB
patch
obsolete
>/* test for BZ 211335 */ >#include <fcntl.h> >#include <stdio.h> >#include <stdlib.h> >#include <string.h> >#include <unistd.h> > >#define TEST_FILE_NAME "directIO_memory_leak" >#define PAGE_SIZE (4096) >#define BUFFER_ALIGNMENT PAGE_SIZE >#define BUFFER_ALIGN (PAGE_SIZE - 1) > >/* how much memory do you want to lost today? */ >/* 100 MB */ >#define LOST_PAGES 25600 >#define LOST_MEM (PAGE_SIZE * LOST_PAGES) > >int write_buffer(int fd, char *buffer, ssize_t count) >{ > ssize_t ret; > > while (count > 0) { > ret = write(fd, buffer, count); > if (ret < 0) { > return -1; > } > buffer += ret; > count -= ret; > } > return 0; >} > >int main() >{ > int fout, i; > char *buf; > char *aligned_buf; > > /* create file with a gap */ > printf("Creating file with gap\n"); > > fout = open(TEST_FILE_NAME, O_CREAT | O_TRUNC | O_WRONLY); > if (fout < 0) { > perror("creating new file"); > return 1; > } > if (0 > lseek(fout, LOST_MEM, SEEK_SET)) { > perror("lseek"); > return 1; > } > i = 0x12; > if (1 != write(fout, &i, 1)) { > perror("write"); > return 1; > } > close(fout); > > printf("File created\n"); > > printf("Open test file\n"); > > /* create and align buffer to BUFFER_ALIGNMENT */ > buf = (char *)malloc(LOST_MEM + BUFFER_ALIGNMENT); > if (buf == NULL) { > printf("error allocating memory\n"); > return 1; > } > aligned_buf = (char *) (((long)buf & ~BUFFER_ALIGN) + BUFFER_ALIGNMENT); > > memset(aligned_buf, 0x12, LOST_MEM); > > fout = open(TEST_FILE_NAME, O_WRONLY | O_DIRECT); > if (fout < 0) { > perror("open"); > return 1; > } > > printf("Write test file\n"); > > for (i = 0; i < LOST_PAGES; i++) { > > printf("\rPage: %d", i); > fflush(stdout); > > if (0 > write_buffer(fout, aligned_buf + (i * PAGE_SIZE), PAGE_SIZE)) { > perror("write_buffer"); > return 1; > } > } > close(fout); > > printf("\nFreeing allocated memory\n"); > free(buf); > > /* memory is lost and will not be freed with BZ211335 */ > > printf("Done\n"); > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 211335
:
138819
| 154814