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=-0.6 required=3.0 tests=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 54534C433DF for ; Fri, 22 May 2020 16:23:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E895A2070A for ; Fri, 22 May 2020 16:23:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="GrI9SuZZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E895A2070A 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 4D9FE80008; Fri, 22 May 2020 12:23:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 485BA80007; Fri, 22 May 2020 12:23:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3752880008; Fri, 22 May 2020 12:23:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0132.hostedemail.com [216.40.44.132]) by kanga.kvack.org (Postfix) with ESMTP id 1F47580007 for ; Fri, 22 May 2020 12:23:40 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 990FA688B for ; Fri, 22 May 2020 16:23:39 +0000 (UTC) X-FDA: 76844875758.27.smash30_59f7b31a7eb07 X-HE-Tag: smash30_59f7b31a7eb07 X-Filterd-Recvd-Size: 3735 Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Fri, 22 May 2020 16:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=kkN05n8AwCXofpqby7bmdZ4Wpf27jnFTOS+pMiMfGAc=; b=GrI9SuZZySt1tElKW+7wdSmUym jsPk8svSB7JtRPm767hAejK6eW134ekobve4Zk5UYQV9RuFV+Ba/4DaXh3Q/j5S6dPaZ0VL9Qbdya TfblH5j8eA/r3WmSUMq6UJLrfsfbFEyALZQZCSq4IIPoKV9xHiIPZCMsSbe1WbIFJEz03rl3Soa8n QmaOWP66+wtIyMPkBhiBZeK3TFcZl6N27s5njC525N6gI1zcmm6P50GSkyUDFF5ZHeoHEg5Lx9LVj UIFE/9ZBMDqpb3Zds+L8WifHgImjKDz7e3nw2jQOJ/1becU2Qm0c8nN7aslucQUE1IT5KQ39lhZZw jObs8Cfg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jcASF-0005wj-FZ; Fri, 22 May 2020 16:23:27 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id D785C306102; Fri, 22 May 2020 18:23:18 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6E72C20B5D17E; Fri, 22 May 2020 18:23:18 +0200 (CEST) Date: Fri, 22 May 2020 18:23:18 +0200 From: Peter Zijlstra To: "Sebastian A. Siewior" Cc: "Ahmed S. Darwish" , Ingo Molnar , Will Deacon , Thomas Gleixner , "Paul E. McKenney" , Steven Rostedt , LKML , Andrew Morton , Konstantin Khlebnikov , linux-mm@kvack.org Subject: Re: [PATCH v1 02/25] mm/swap: Don't abuse the seqcount latching API Message-ID: <20200522162318.GV317569@hirez.programming.kicks-ass.net> References: <20200519214547.352050-1-a.darwish@linutronix.de> <20200519214547.352050-3-a.darwish@linutronix.de> <20200522145707.GO325280@hirez.programming.kicks-ass.net> <20200522151705.vwfua5a4lhzcagea@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200522151705.vwfua5a4lhzcagea@linutronix.de> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, May 22, 2020 at 05:17:05PM +0200, Sebastian A. Siewior wrote: > On 2020-05-22 16:57:07 [+0200], Peter Zijlstra wrote: > > > @@ -725,21 +735,48 @@ void lru_add_drain_all(void) > > > if (WARN_ON(!mm_percpu_wq)) > > > return; > > > > > > > > + this_gen = READ_ONCE(lru_drain_gen); > > > + smp_rmb(); > > > > this_gen = smp_load_acquire(&lru_drain_gen); > > > > > > mutex_lock(&lock); > > > > > > /* > > > + * (C) Exit the draining operation if a newer generation, from another > > > + * lru_add_drain_all(), was already scheduled for draining. Check (A). > > > */ > > > + if (unlikely(this_gen != lru_drain_gen)) > > > goto done; > > > > > > > > + WRITE_ONCE(lru_drain_gen, lru_drain_gen + 1); > > > + smp_wmb(); > > > > You can leave this smp_wmb() out and rely on the smp_mb() implied by > > queue_work_on()'s test_and_set_bit(). > > This is to avoid smp_store_release() ? store_release would have the barrier on the other end. If you read the comments (I so helpfully cut out) you'll see it wants to order against later stores, not ealier.