From owner-freebsd-hackers@FreeBSD.ORG Fri Sep 5 07:02:52 2014 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6E1F0CEC for ; Fri, 5 Sep 2014 07:02:52 +0000 (UTC) Received: from mail-ie0-x234.google.com (mail-ie0-x234.google.com [IPv6:2607:f8b0:4001:c03::234]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3CC7C1465 for ; Fri, 5 Sep 2014 07:02:52 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id rl12so12811058iec.25 for ; Fri, 05 Sep 2014 00:02:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=UlHE8pbxzzoNi3bVt3VCf2wxZ1qpAzevT86lapvsVq0=; b=uP+q7LnjEV80sLMTNmVsP7UrKpG8T7skU0lPTh10AU0F2mtVQ48L5OihMT624GRTX6 PC4dqvCoG1MYVpn9YVbUjJh/y/3zUSGMBCQCCtDoFI4l6/5Al2GcB5b1Ol6JF+857EZ0 jEKX7/eVH9pmwrKRw74idbME1wN9FjseJYqeV1bBjCD7r/7rfIq1j2eIT4n2s60UJhQz TZsiagp3/GgB5C6ibFRccJhdDkxIzpjJ9/wH46C0lw+1zT3BqEuRTm51XVRRrOASvg/s bjWjh45BsKuJyemwSciHrooJdv4W/VGkRh1ODYCLkNx4KySpnnDyawKK0/3eKYFrMu4L Yv6A== MIME-Version: 1.0 X-Received: by 10.42.137.194 with SMTP id z2mr36971ict.85.1409900571625; Fri, 05 Sep 2014 00:02:51 -0700 (PDT) Received: by 10.43.178.200 with HTTP; Fri, 5 Sep 2014 00:02:51 -0700 (PDT) Reply-To: alc@freebsd.org In-Reply-To: <540903FF.6010602@degoeje.nl> References: <540903FF.6010602@degoeje.nl> Date: Fri, 5 Sep 2014 02:02:51 -0500 Message-ID: Subject: Re: mmap MAP_NOSYNC regression in 10.x From: Alan Cox To: Pieter de Goeje , Konstantin Belousov Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.18-1 Cc: hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Sep 2014 07:02:52 -0000 On Thu, Sep 4, 2014 at 7:29 PM, Pieter de Goeje wrote: > After upgrading my month old 10-stable installation today (to r271093) , > I've noticed a that the kernel no longer honors the MAP_NOSYNC flag. > Attached is a demonstration program that highlights the issue (also > available here: http://pastebin.com/y0kvdn0r ). > > The program creates and mmap()s a 200MiB file and repeatedly writes zeros > to it. The expected behavior is that under normal circumstances (no memory > pressure), the dirtied pages are not flushed to disk. Observed is however > that every ~30 seconds the syncer kicks in and basically halts the program > while it does its job. The program prints a line everytime the throughput > drops below 500MBps, well below memory bandwidth. > > mmap() is called like this: > > void *p = mmap(NULL, len, PROT_READ | PROT_WRITE, > MAP_SHARED | MAP_NOSYNC | MAP_ALIGNED_SUPER, fd, 0); > > Sample output: > > write... > zeroing: 209.6 MB > ...write: 5.839s > mmap... > ...mmap: 0.000s > 20.1s: memset #259: 34.7MBps - stalled > 55.7s: memset #810: 34.7MBps - stalled > 91.3s: memset #1359: 34.6MBps - stalled > 100.0s: memset #1522: 3938.5MBps > overall bandwidth: 3190.6MBps > munmap... > ...munmap: 5.796s > done > > (this is a rather old system) > > If necessary I'm willing to find out the exact commit that caused the > problem. > > That's not necessary. This is a bug in the page fault handler's new fast path.