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=-2.5 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 2CD5BC4CED1 for ; Fri, 4 Oct 2019 12:27:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D93AB215EA for ; Fri, 4 Oct 2019 12:27:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D93AB215EA Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 56CB76B0003; Fri, 4 Oct 2019 08:27:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 51C7B6B0005; Fri, 4 Oct 2019 08:27:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4326B6B0007; Fri, 4 Oct 2019 08:27:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0093.hostedemail.com [216.40.44.93]) by kanga.kvack.org (Postfix) with ESMTP id 1B8FE6B0003 for ; Fri, 4 Oct 2019 08:27:31 -0400 (EDT) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 6458182437D7 for ; Fri, 4 Oct 2019 12:27:30 +0000 (UTC) X-FDA: 76006027860.09.toys30_74778c9dcc22 X-HE-Tag: toys30_74778c9dcc22 X-Filterd-Recvd-Size: 2192 Received: from mx1.suse.de (mx2.suse.de [195.135.220.15]) by imf02.hostedemail.com (Postfix) with ESMTP for ; Fri, 4 Oct 2019 12:27:29 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 7EC52AD14; Fri, 4 Oct 2019 12:27:28 +0000 (UTC) Date: Fri, 4 Oct 2019 14:27:27 +0200 From: Michal Hocko To: Matthew Wilcox Cc: Konstantin Khlebnikov , linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/swap: piggyback lru_add_drain_all() calls Message-ID: <20191004122727.GA10845@dhcp22.suse.cz> References: <157018386639.6110.3058050375244904201.stgit@buzz> <20191004121017.GG32665@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191004121017.GG32665@bombadil.infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) 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 04-10-19 05:10:17, Matthew Wilcox wrote: > On Fri, Oct 04, 2019 at 01:11:06PM +0300, Konstantin Khlebnikov wrote: > > This is very slow operation. There is no reason to do it again if somebody > > else already drained all per-cpu vectors after we waited for lock. > > + seq = raw_read_seqcount_latch(&seqcount); > > + > > mutex_lock(&lock); > > + > > + /* Piggyback on drain done by somebody else. */ > > + if (__read_seqcount_retry(&seqcount, seq)) > > + goto done; > > + > > + raw_write_seqcount_latch(&seqcount); > > + > > Do we really need the seqcount to do this? Wouldn't a mutex_trylock() > have the same effect? Yeah, this makes sense. From correctness point of view it should be ok because no caller can expect that per-cpu pvecs are empty on return. This might have some runtime effects that some paths might retry more - e.g. offlining path drains pcp pvces before migrating the range away, if there are pages still waiting for a worker to drain them then the migration would fail and we would retry. But this not a correctness issue. -- Michal Hocko SUSE Labs