Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2398142ybb; Sat, 21 Mar 2020 21:32:35 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsSq2JVYdtP/2Fl2+c5328QxBXMOjAzMUZcZdQJBuu+37ugHBvZQX2LnqEhtT/J5k/eI8X7 X-Received: by 2002:a9d:7a8:: with SMTP id 37mr268919oto.209.1584851555595; Sat, 21 Mar 2020 21:32:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584851555; cv=none; d=google.com; s=arc-20160816; b=u3k16CkPuxa4einb54IxXSXEskIyPd+09mIL9MmsT6kbmYE5cOUxV2dRdCti2CFwdR kt0eXAGTtgXuvbfuiKGFEOTblVOqTxlv5gPgBYn11VWA4c65rb7/NleGF6zWKdFRZnfx wBcPjHF9PjUCQiaKftQSAuYdRwjHcvK/2pwwnom1D5L6IjG2wMeqy2kGL/IWgohJHTSS 4nNHPM5r4uYeMqYhCSnwjpsvvR2n49m74Sv2ujtwg8N+IWqi35mruPMPBXCAW+Y/BQ6h u0J7tLutVSCkUkdpPezfNrOBHSAAvb0Pl8OlMEa2l/7NziYJioh8gSa0aUDZVQA6yVzF cJ/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=S1GLQvNFmJ7L6rAS1JDt19XeQkURzyTNDvvScem4zqk=; b=Rqh1QczOA11K4bOvEdGqB8tU5/Ahy3lOxZPH8nemTAeOKLshORNagjfrnbEheGrqHq pU8EL64Zqv5qiVEyvsfnm345WEswu16V45aiYM+1zObpIQESFX+dNNEgf/Bs3+SLrsAd BGxQ/5m5i9vz7WiriJ8RAE58uLO8MAUjklaqVLjej/MsHiOfXFwxVG5exwIv2QI9xBHU AHRes/91UrCDo28qhRWRJmQSdvqNchnCET+5b/PdCB5B6tC/95X/7xOeVg4lB2CNdCtL KNvgMJSQAjFLQa+O30vJ+XJzmQn4cTvXM221+fFY0gVEq9kerW/wPNIq41inGiMX7GlI Sr4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qDazwTlA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l18si5579753otk.246.2020.03.21.21.32.10; Sat, 21 Mar 2020 21:32:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qDazwTlA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725797AbgCVEbo (ORCPT + 99 others); Sun, 22 Mar 2020 00:31:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:60740 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725554AbgCVEbo (ORCPT ); Sun, 22 Mar 2020 00:31:44 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 86C77206F9; Sun, 22 Mar 2020 04:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584851503; bh=+5nxVvLDglesqKoMyyHWiUfsl0yEfapg6YZP612YgTo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qDazwTlAD5YbbcoB54nxxYPbplX8cKKt2CJjlCy/obCgoCHH++MpPYAP3pc4Kcywz 7PXsl5/3aOqw6vOoJu2R9yD9jFgVxWUk99JQaNYV8e3sl96XXLEUosrfazWkoATa2T cOHzXpoUVYrJqk3haEU/rSjFvim6ogB0js00fPcE= Date: Sat, 21 Mar 2020 21:31:42 -0700 From: Andrew Morton To: Rafael Aquini Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, shuah@kernel.org, shakeelb@google.com Subject: Re: [PATCH] tools/testing/selftests/vm/mlock2-tests: fix mlock2 false-negative errors Message-Id: <20200321213142.597e23af955de653fc4db7a1@linux-foundation.org> In-Reply-To: <20200322020326.GB1068248@t490s> References: <20200322013525.1095493-1-aquini@redhat.com> <20200321184352.826d3dba38aecc4ff7b32e72@linux-foundation.org> <20200322020326.GB1068248@t490s> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 21 Mar 2020 22:03:26 -0400 Rafael Aquini wrote: > > > + * In order to sort out that race, and get the after fault checks consistent, > > > + * the "quick and dirty" trick below is required in order to force a call to > > > + * lru_add_drain_all() to get the recently MLOCK_ONFAULT pages moved to > > > + * the unevictable LRU, as expected by the checks in this selftest. > > > + */ > > > +static void force_lru_add_drain_all(void) > > > +{ > > > + sched_yield(); > > > + system("echo 1 > /proc/sys/vm/compact_memory"); > > > +} > > > > What is the sched_yield() for? > > > > Mostly it's there to provide a sleeping gap after the fault, whithout > actually adding an arbitrary value with usleep(). > > It's not a hard requirement, but, in some of the tests I performed > (whithout that sleeping gap) I would still see around 1% chance > of hitting the false-negative. After adding it I could not hit > the issue anymore. It's concerning that such deep machinery as pagevec draining is visible to userspace. I suppose that for consistency and correctness we should perform a drain prior to each read from /proc/*/pagemap. Presumably this would be far too expensive. Is there any other way? One such might be to make the MLOCK_ONFAULT pages bypass the lru_add_pvecs?