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.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,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 67861C4360C for ; Fri, 4 Oct 2019 12:10:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 27995222BE for ; Fri, 4 Oct 2019 12:10:20 +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="cwx4hIJe" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 27995222BE 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 CCC926B0003; Fri, 4 Oct 2019 08:10:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C7E316B0005; Fri, 4 Oct 2019 08:10:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B93938E0003; Fri, 4 Oct 2019 08:10:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0035.hostedemail.com [216.40.44.35]) by kanga.kvack.org (Postfix) with ESMTP id 946CA6B0003 for ; Fri, 4 Oct 2019 08:10:19 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 27072180AD803 for ; Fri, 4 Oct 2019 12:10:19 +0000 (UTC) X-FDA: 76005984558.08.fog78_2be82ee08103 X-HE-Tag: fog78_2be82ee08103 X-Filterd-Recvd-Size: 2389 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Fri, 4 Oct 2019 12:10:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=fqX+HVWO3sNM75kjP5U6ICYzph+15bTG0LHXrFap22M=; b=cwx4hIJePaeGPIOtObfGjpKFY rIapApyhjZgE6DloCdBY++lzFWXMvfxug3tnprRS+nJdbshhM/QtN+wooheYnJJzkmcMUY3+LDUgp TTKbnjemCt/mIEyGRd5Rf6K5rKr6FJaafP4TKpAopQ9ey5Ur9HoqBfl0EKDbYVeC4WyMO1lg4H9b1 ufo3LDnUXXNlBAPRaW9NJjj7+WgcbSpZnF1zlvwzpGHZRTak6B3cXc2acMUfk9VfoIaAu/9nz91Jy RpsibJy99//hkcNU9uzg8WgfuUEpW+0QtvD8BpV63mHJNxx4LYIvmNnMJtXFhT4P3U3gmWrPjKpq+ tco43++YA==; Received: from willy by bombadil.infradead.org with local (Exim 4.92.2 #3 (Red Hat Linux)) id 1iGMPZ-0000lj-CB; Fri, 04 Oct 2019 12:10:17 +0000 Date: Fri, 4 Oct 2019 05:10:17 -0700 From: Matthew Wilcox To: Konstantin Khlebnikov Cc: linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/swap: piggyback lru_add_drain_all() calls Message-ID: <20191004121017.GG32665@bombadil.infradead.org> References: <157018386639.6110.3058050375244904201.stgit@buzz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <157018386639.6110.3058050375244904201.stgit@buzz> User-Agent: Mutt/1.12.1 (2019-06-15) 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, 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?