From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C97FEC433E0 for ; Mon, 11 Jan 2021 15:41:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B754E20637 for ; Mon, 11 Jan 2021 15:41:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B754E20637 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BCA836B00C7; Mon, 11 Jan 2021 10:41:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B7A6A6B00D2; Mon, 11 Jan 2021 10:41:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A907B6B00D5; Mon, 11 Jan 2021 10:41:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0102.hostedemail.com [216.40.44.102]) by kanga.kvack.org (Postfix) with ESMTP id 9428D6B00C7 for ; Mon, 11 Jan 2021 10:41:32 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 52CB8180AD81A for ; Mon, 11 Jan 2021 15:41:32 +0000 (UTC) X-FDA: 77693908824.23.pull85_440d8432750d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 18E033760C for ; Mon, 11 Jan 2021 15:41:32 +0000 (UTC) X-HE-Tag: pull85_440d8432750d X-Filterd-Recvd-Size: 3759 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Mon, 11 Jan 2021 15:41:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=Du7HL0ZcY3+gw6vspkxKy6bfBD74WLNhIUyewLRApMU=; b=uYKmflEGHiNHpg2/tADuDADM1p fD0ENgR+uIjxc5QRlqmSsjI91WEr5S9/kpd3/mep6V8jDhZuKgWmQLLW6bjVO9zMsyFd9h9bHvymc XAoDjm3KqvA+lBIPpHbtQsIViCFibNOQJn/hKrS6buWI/rfHIABwQExHo6xYxnIcwMpTKopXB4yuM v7rcliqdATBESMrLvnkXsuiYLXyEFPNPNgW//TUzJcmgRtRneiicUxGv7Vg1j3y2ifxJXiyRxXzn4 dPg9fNfgPR2xTZlpeymlHjiTyVl8Lhlpb/LYJYg7vCjetuQ/JQGovaS2jh6g2bduSwg/OofnLN0hA T7xgX/kw==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1kyzJs-003RPU-QV; Mon, 11 Jan 2021 15:41:26 +0000 Date: Mon, 11 Jan 2021 15:41:24 +0000 From: Matthew Wilcox To: anton@ozlabs.org Cc: linux-mm@kvack.org, "Liam R. Howlett" Subject: Re: brk1 tests the wrong thing Message-ID: <20210111154124.GF35215@casper.infradead.org> References: <20201210200736.GA7338@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201210200736.GA7338@casper.infradead.org> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000205, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: ping On Thu, Dec 10, 2020 at 08:07:36PM +0000, Matthew Wilcox wrote: > Linux has this horrendously complicated anon_vma structure that you don't > care about, but the upshot is that after calling fork(), each process > that calls brk() gets a _new_ VMA created. That is, after calling brk() > the first time, the process address space looks like this: > > 557777fab000-557777ff0000 rw-p 00000000 00:00 0 [heap] > 557777ff0000-557777ff1000 rw-p 00000000 00:00 0 [heap] > > so what brk1 is actually testing is how long it takes to create & destroy > a new VMA. This does not match what most programs do -- most will call > exec() which resets the anon_vma structures and starts each program off > with its own heap. And if you do have a multi-process program which > uses brk(), chances are it doesn't just oscillate betwee zero and one > extra pages of heap compared to its parent. > > A better test starts out by allocating one page on the heap and then > throbs between one and two pages instead of throbbing between zero and > one page. That means we're actually testing expanding and contracting > the heap instead of creating and destroying a new heap. > > For realism, I wanted to add actually accessing the memory in the new > heap, but that doesn't work for the threaded case -- another thread > might remove the memory you just allocated while you're allocating it. > Threaded programs give each thread its own heap anyway, so this is > kind of a pointless syscall to ask about its threaded scalability. > > Anyway, here's brk2.c. It is not very different from brk1.c, but the > performance results are quite different (actually worse by about 10-15%). > > > #include > #include > #include > > char *testcase_description = "brk unshared increase/decrease of one page"; > > void testcase(unsigned long long *iterations, unsigned long nr) > { > unsigned long page_size = getpagesize(); > void *addr = sbrk(page_size) + page_size; > > while (1) { > addr += page_size; > assert(brk(addr) == 0); > > addr -= page_size; > assert(brk(addr) == 0); > > (*iterations) += 2; > } > } >