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=-3.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, INCLUDES_PATCH,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 317BEC433E1 for ; Mon, 25 May 2020 06:44:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EABEC2075F for ; Mon, 25 May 2020 06:44:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BF+jrK+t" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EABEC2075F 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 74A658001B; Mon, 25 May 2020 02:44:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6FA268000E; Mon, 25 May 2020 02:44:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5E8AF8001B; Mon, 25 May 2020 02:44:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id 450F08000E for ; Mon, 25 May 2020 02:44:41 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DBF404DC5 for ; Mon, 25 May 2020 06:44:40 +0000 (UTC) X-FDA: 76854303120.08.eyes11_bbb03cd37b41 X-HE-Tag: eyes11_bbb03cd37b41 X-Filterd-Recvd-Size: 5884 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Mon, 25 May 2020 06:44:40 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id f5so7422743wmh.2 for ; Sun, 24 May 2020 23:44:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=j3A3p7RwQnDPKk8y171UjzjlpaAeUZfU5UzTOAlkuUc=; b=BF+jrK+tHyMuCWDta7VDyvEPQQBuOXK660UPEDnJ5HomWsjm8jnp2ix+pSnmD3A3RN hXXxCfR7wECpK13pp1c5ItPfD9kNbXwQppSWIyBWuT2hiasBxW2Qe/SjOdT+OE39DS5Y MHk/dvzCkc8cMDsqFugK04WYObVVcXDDp6uqbvdDhUPNDV/c5Kja+po/BOBohxrS+bH6 GBTJmU2D3tV/MIPD2fAPVYbKcCSwM0ZtCX4F0vvBSd4wvcbkeCvmKX30itj7GxwgJF/N 2xVK+VLRJ71VENspTC9CxSaCY8tppMWKDorEHoAtxAgFCT8jFyvY1ART3t1dPqb5V2Yh hi5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=j3A3p7RwQnDPKk8y171UjzjlpaAeUZfU5UzTOAlkuUc=; b=eKpu0z/XoQOLABbHcI0IJxMTlkFFVzVZUP/oHwwgVZO0fC/PNH0qh5BCGQYefL/2D4 esfMsh8qfB2SRUzKvwBvc/h0kzSHjcXQ5WBOeEPIIhcgIYanW2errydqxSFP0fxwx2er 4NFHwvP4rAkeyw+G7n4H/6ymFMNB28+lXtHUgpen8YpqDDgtuiX6b0eWYx6ZeKEiP5E/ 8KtBFS4CgSGfVES0OA6tCz1O1sJIJ0lbqxNpmDO15I2ARAwYZn1xqNl/yWS+pXL94un0 RB3Cp0iMObtPnt9lIcBSjGF4v33tDmBIjIXOzBeh7w8g1svx0PwgQgbIQqYQWTId/enB 9yGA== X-Gm-Message-State: AOAM5328mOywcryFoo417PLeYjADAckT1VyOAYTHWL7Ht4W+Y2thIaUI 91eyzMiqT7omgaL3kSx/ETs= X-Google-Smtp-Source: ABdhPJw0DTykOnvt5kt6wjW8ImOFwP1s74wj30T4UGm2lNJ5nn5j3clCR8grgAnHyZhZR1e29HlyoA== X-Received: by 2002:a1c:b7d5:: with SMTP id h204mr5178757wmf.39.1590389079338; Sun, 24 May 2020 23:44:39 -0700 (PDT) Received: from gmail.com (54033286.catv.pool.telekom.hu. [84.3.50.134]) by smtp.gmail.com with ESMTPSA id d18sm15018861wrn.34.2020.05.24.23.44.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 May 2020 23:44:38 -0700 (PDT) Date: Mon, 25 May 2020 08:44:36 +0200 From: Ingo Molnar To: Sebastian Andrzej Siewior Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Steven Rostedt , Will Deacon , Thomas Gleixner , "Paul E . McKenney" , Linus Torvalds , Matthew Wilcox , Andrew Morton , linux-mm@kvack.org Subject: Re: [PATCH v2 3/7] mm/swap: Use local_lock for protection Message-ID: <20200525064436.GA329373@gmail.com> References: <20200524215739.551568-1-bigeasy@linutronix.de> <20200524215739.551568-4-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200524215739.551568-4-bigeasy@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: * Sebastian Andrzej Siewior wrote: > From: Ingo Molnar > > The various struct pagevec per CPU variables are protected by disabling > either preemption or interrupts across the critical sections. Inside > these sections spinlocks have to be acquired. > diff --git a/mm/swap.c b/mm/swap.c > index bf9a79fed62d7..4f965292044ca 100644 > --- a/mm/swap.c > +++ b/mm/swap.c > @@ -35,6 +35,7 @@ > #include > #include > #include > +#include > > #include "internal.h" > > @@ -44,14 +45,29 @@ > /* How many pages do we try to swap or page in/out together? */ > int page_cluster; > > -static DEFINE_PER_CPU(struct pagevec, lru_add_pvec); > -static DEFINE_PER_CPU(struct pagevec, lru_rotate_pvecs); > -static DEFINE_PER_CPU(struct pagevec, lru_deactivate_file_pvecs); > -static DEFINE_PER_CPU(struct pagevec, lru_deactivate_pvecs); > -static DEFINE_PER_CPU(struct pagevec, lru_lazyfree_pvecs); > +/* Protecting lru_rotate_pvecs */ > +struct lru_rotate_pvecs { > + struct local_lock lock; > + struct pagevec pvec; > +}; > +static DEFINE_PER_CPU(struct lru_rotate_pvecs, lru_rotate_pvecs) = { > + .lock = INIT_LOCAL_LOCK(lock), > +}; > + > +/* Protecting the following struct pagevec */ > +struct lru_pvecs { > + struct local_lock lock; > + struct pagevec lru_add_pvec; > + struct pagevec lru_deactivate_file_pvecs; > + struct pagevec lru_deactivate_pvecs; > + struct pagevec lru_lazyfree_pvecs; Ack on coalescing these into the 'struct lru_pvecs' helper structure, but a minor namespace organization nit: I'd drop the _pvec/_pvecs postfix from the field names, i.e. make it something like this: /* Protecting the following struct pagevec */ struct lru_pvecs { struct local_lock lock; struct pagevec lru_add; struct pagevec lru_deactivate_file; struct pagevec lru_deactivate; struct pagevec lru_lazyfree; With that change, usage is a straightforward: pvec->lru_deactivate instead of the double-pvec name: pvec->lru_deactivate_pvec > + local_lock_irqsave(&lru_rotate_pvecs.lock, flags); Also: > + pvec = this_cpu_ptr(&lru_rotate_pvecs.pvec); s/lru_rotate_pvecs /lru_rotate_pvec it's a single pagevec, using plural is confusing when reading the code. I'd also suggest adding a comment explaining why the lru_rotate_pvec local lock is split away from lru_add/deactivate/deactivate/lazyfree pagevec local lock. Thanks, Ingo