Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752028AbbHQXXq (ORCPT ); Mon, 17 Aug 2015 19:23:46 -0400 Received: from mail-pa0-f41.google.com ([209.85.220.41]:34650 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751102AbbHQXXo (ORCPT ); Mon, 17 Aug 2015 19:23:44 -0400 Date: Mon, 17 Aug 2015 16:22:21 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Andrey Konovalov cc: Andrew Morton , Michal Hocko , Johannes Weiner , Vladimir Davydov , Hugh Dickins , Miklos Szeredi , Jason Low , Cesar Eduardo Barros , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dmitry Vyukov , Kostya Serebryany , Alexander Potapenko Subject: Re: Potential data race in SyS_swapon In-Reply-To: Message-ID: References: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1327 Lines: 31 On Fri, 7 Aug 2015, Andrey Konovalov wrote: > > We are working on a dynamic data race detector for the Linux kernel > called KernelThreadSanitizer (ktsan) > (https://github.com/google/ktsan/wiki). > > While running ktsan on the upstream revision 21bdb584af8c with trinity > we got a few reports from SyS_swapon, here is one of them: > > ================================================================== > ThreadSanitizer: data-race in SyS_swapon > > Read of size 8 by thread T307 (K7621): > [< inlined >] SyS_swapon+0x3c0/0x1850 SYSC_swapon mm/swapfile.c:2395 > [] SyS_swapon+0x3c0/0x1850 mm/swapfile.c:2345 > [] ia32_do_call+0x1b/0x25 > > Looks like the swap_lock should be taken when iterating through the > swap_info array on lines 2392 - 2401. Thanks for the report. Actually, lines 2392 to 2401 just look redundant to me: it looks as if claim_swapfile() should do all that's needed, though in fact it doesn't quite. I'll send akpm a patch and Cc you, no need to retest since the offending lines just won't be there. Hugh -- 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/