Messages in this thread | | | Date | Thu, 24 Jun 2004 15:40:02 -0700 | From | William Lee Irwin III <> | Subject | Re: [discuss] Re: 32-bit dma allocations on 64-bit platforms |
| |
/* On Thu, Jun 24, 2004 at 03:37:50PM -0700, William Lee Irwin III wrote: > Have you tried with 2.6.7? The following program fails to trigger anything > like what you've mentioned, though granted it was a 512MB allocation on > a 1GB machine. swapoff(2) merely fails.
And after fixing a bug in the program, not even that fails: */
#include <stdint.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <strings.h> #include <sys/swap.h>
int main(int argc, char * const argv[]) { int i; long pagesize, physpages; size_t size; void *p;
pagesize = sysconf(_SC_PAGE_SIZE); if (pagesize < 0) { perror("failed to determine pagesize"); exit(EXIT_FAILURE); } physpages = sysconf(_SC_PHYS_PAGES); if (physpages < 0) { perror("failed to determine physical memory capacity"); exit(EXIT_FAILURE); } if ((size_t)(physpages/2) > SIZE_MAX/pagesize) { fprintf(stderr, "insufficient virtualspace capacity\n"); exit(EXIT_FAILURE); } size = (physpages/2)*pagesize; p = malloc(size); if (!p) { perror("allocation failure"); exit(EXIT_FAILURE); } bzero(p, size); for (i = 1; i < argc; ++i) { if (swapoff(argv[i])) { perror("swapoff failure"); fprintf(stderr, "failed to offline %s\n", argv[i]); exit(EXIT_FAILURE); } } return EXIT_SUCCESS; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |