From owner-freebsd-bugs Tue Jan 30 9:30:26 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 73D1537B491 for ; Tue, 30 Jan 2001 09:30:06 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f0UHU6C07357; Tue, 30 Jan 2001 09:30:06 -0800 (PST) (envelope-from gnats) Date: Tue, 30 Jan 2001 09:30:06 -0800 (PST) Message-Id: <200101301730.f0UHU6C07357@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Bruce Evans Subject: Re: bin/24732: cmp can not compare files lager 2GB but smaller 4GB Reply-To: Bruce Evans Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/24732; it has been noted by GNATS. From: Bruce Evans To: Dmitry Kazarov Cc: freebsd-gnats-submit@FreeBSD.org Subject: Re: bin/24732: cmp can not compare files lager 2GB but smaller 4GB Date: Wed, 31 Jan 2001 04:24:15 +1100 (EST) On Tue, 30 Jan 2001, Dmitry Kazarov wrote: > Sorry, I do not understand why compare MAX(...) to SIZE_T_MAX. > IMHO, mmap maps the file into process memory so both files together should > fit into process accessible address space which is less then SIZE_T_MAX (my > expirements with cmp showed that is about 2430MB, on Solaris 2.4 it was 2GB > only). mmap()'s `len' arg has type size_t, so lengths larger than SIZE_T_MAX can't be passed to mmap() for it to check (and fail on). > So it's nessesary to compare (len1+skip1%pagesize + len2+skip2%pagesize) to > 2430MB (for my system). mmap() will check this if the full lengths can be passed to it. Since their are 2 mmap()s, there is a machine-dependent amount of space between them. PAGE_SIZE is probably sufficient, but you have to look at the implementation to tell. Your 2430MB must have some slop for this. > Cause, reverting to c_special on mmap failure could be a better way but, > IMHO, the best solution would be proposal of Poul-Henning Kamp > ( http://www.freebsd.org/cgi/query-pr.cgi?pr=18589 ): > "Add a loop around the mmap/compare operation which operates on some > moderate amount of data each iteration." I agree. cp uses 8MB for the moderate amount. So does xinstall for its file comparison function. xinstall also falls back to read() when mmap() fails, and has a -M flag to prevent use of mmap(). Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message