From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758290Ab2EAPjF (ORCPT ); Tue, 1 May 2012 11:39:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40940 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757241Ab2EAPjD convert rfc822-to-8bit (ORCPT ); Tue, 1 May 2012 11:39:03 -0400 From: Jeff Moyer To: KOSAKI Motohiro Cc: Jan Kara , Michael Kerrisk , LKML , linux-man@vger.kernel.org, linux-mm@kvack.org, mgorman@suse.de, npiggin@gmail.com, Andrea Arcangeli , Woodman Subject: Re: [PATCH] Describe race of direct read and fork for unaligned buffers References: <1335778207-6511-1-git-send-email-jack@suse.cz> X-PGP-KeyID: 1F78E1B4 X-PGP-CertKey: F6FE 280D 8293 F72C 65FD 5A58 1FF8 A7CA 1F78 E1B4 X-PCLoadLetter: What the f**k does that mean? Date: Tue, 01 May 2012 11:38:33 -0400 In-Reply-To: (KOSAKI Motohiro's message of "Tue, 1 May 2012 11:34:04 -0400") Message-ID: User-Agent: Gnus/5.110011 (No Gnus v0.11) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org KOSAKI Motohiro writes: > On Tue, May 1, 2012 at 11:11 AM, Jeff Moyer wrote: >> KOSAKI Motohiro writes: >> >>>> Hello, >>>> >>>> Thank you revisit this. But as far as my remember is correct, this issue is NOT >>>> unaligned access issue. It's just get_user_pages(_fast) vs fork race issue. i.e. >>>> DIRECT_IO w/ multi thread process should not use fork(). >>> >>> The problem is, fork (and its COW logic) assume new access makes cow break, >>> But page table protection can't detect a DMA write. Therefore DIO may override >>> shared page data. >> >> Hm, I've only seen this with misaligned or multiple sub-page-sized reads >> in the same page.  AFAIR, aligned, page-sized I/O does not get split. >> But, I could be wrong... > > If my remember is correct, the reproducer of past thread is misleading. > > dma_thread.c in > http://lkml.indiana.edu/hypermail/linux/kernel/0903.1/01498.html has > align parameter. But it doesn't only change align. Because of, every > worker thread read 4K (pagesize), then > - when offset is page aligned > -> every page is accessed from only one worker > - when offset is not page aligned > -> every page is accessed from two workers > > But I don't remember why two threads are important things. hmm.. I'm > looking into the code a while. > Please don't 100% trust me. I bet Andrea or Larry would remember the details. Cheers, Jeff