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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CBC29C43217 for ; Tue, 12 Apr 2022 07:07:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Mf8m+4vDzBUAXpyAa2/jHdTzdA4NR2Aqzv7iDeERaWg=; b=hbeaQu16d5T9ip Jf9icGsj3T5atyWTxYBV3+QhpT4QRar22RqGeXinEADjEwjQirMZHmqyZXLVU/0VOuFuiRXI60zsp p7wNsNtVaaOaDsjqFZBx7l7G+LX+L47VwdQ2AsC37wpKeSSGCIORQ7/ZRUs0jEELfowm3JpUX1bfv FmTS2FHiczqFKhaDLcbYQUVrZq9kT0/cZ9ijmeFkBOoybDAZdHo8wfWZLFEYriewIecwsbnqvB9d8 PSVvi0r20A4aW8na5iheTiVPzOrxOMoGrMj/hk2d08AXxU6VxBaFF2c/IeCwh+RzZIg5tkNKdzp5t DYiKtItR8eSxzO0Vc1wQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1neAbm-00C3iY-18; Tue, 12 Apr 2022 07:06:38 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1neAbk-00C3i2-Lb for linux-arm-kernel@bombadil.infradead.org; Tue, 12 Apr 2022 07:06:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=C3gL28B3Gc2aOWbp9TEABQMn0ckE3NlAT3ZMfiId2yM=; b=NX/1HLFCyl0vrt8Ykxe6Lw8tiL ibR3HLppnOGAHLzmEZvRQ/ps/npWEuslAuQ2wxMgrPuhsEQkGaiMW2OiO1XheO1U3zr16ITSbJ8Y+ Ae9IZrmFSo1ePtVSKuXbWenTKQO/im6/8EfYem0M57zrvOvDuysy2DB2JtTtAHbPS0gJvq3rTLGCn JABlC1yiyKBFK2laSPj5AeOq1wFEjyTxA5jmTRL8kbQ6/qmVUwnY4arjso2s6ilmC/rusTxHmZQPf mW1ZsqDJP4bqkJcpLqsI2kQVkPz/MBRWHAqfCiikArrTB2F6+jnEO3oGsTxbLbckXcGPgQ4wZQLg5 o54RZ5SQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1neAbS-004F4r-Tz; Tue, 12 Apr 2022 07:06:19 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 6172F98619A; Tue, 12 Apr 2022 09:06:16 +0200 (CEST) Date: Tue, 12 Apr 2022 09:06:16 +0200 From: Peter Zijlstra To: Andrew Morton Cc: Yu Zhao , Stephen Rothwell , linux-mm@kvack.org, Andi Kleen , Aneesh Kumar , Barry Song <21cnbao@gmail.com>, Catalin Marinas , Dave Hansen , Hillf Danton , Jens Axboe , Jesse Barnes , Johannes Weiner , Jonathan Corbet , Linus Torvalds , Matthew Wilcox , Mel Gorman , Michael Larabel , Michal Hocko , Mike Rapoport , Rik van Riel , Vlastimil Babka , Will Deacon , Ying Huang , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, page-reclaim@google.com, x86@kernel.org, Brian Geffon , Jan Alexander Steffens , Oleksandr Natalenko , Steven Barrett , Suleiman Souhlal , Daniel Byrne , Donald Carr , Holger =?iso-8859-1?Q?Hoffst=E4tte?= , Konstantin Kharlamov , Shuang Zhai , Sofia Trinh , Vaibhav Jain Subject: Re: [PATCH v10 05/14] mm: multi-gen LRU: groundwork Message-ID: <20220412070616.GT2731@worktop.programming.kicks-ass.net> References: <20220407031525.2368067-1-yuzhao@google.com> <20220407031525.2368067-6-yuzhao@google.com> <20220411191615.a34959bdcc25ef3f9c16a7ce@linux-foundation.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220411191615.a34959bdcc25ef3f9c16a7ce@linux-foundation.org> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Apr 11, 2022 at 07:16:15PM -0700, Andrew Morton wrote: > > +{ > > + int gen; > > + unsigned long old_flags, new_flags; > > + > > + do { > > + new_flags = old_flags = READ_ONCE(folio->flags); > > + if (!(new_flags & LRU_GEN_MASK)) > > + return false; > > + > > + VM_BUG_ON_FOLIO(folio_test_active(folio), folio); > > + VM_BUG_ON_FOLIO(folio_test_unevictable(folio), folio); > > + > > + gen = ((new_flags & LRU_GEN_MASK) >> LRU_GEN_PGOFF) - 1; > > + > > + new_flags &= ~LRU_GEN_MASK; > > + /* for shrink_page_list() */ > > + if (reclaiming) > > + new_flags &= ~(BIT(PG_referenced) | BIT(PG_reclaim)); > > + else if (lru_gen_is_active(lruvec, gen)) > > + new_flags |= BIT(PG_active); > > + } while (cmpxchg(&folio->flags, old_flags, new_flags) != old_flags); Also; please use the form: unsigned long new, old = READ_ONCE(folio->flags); do { new = /* something */ old; } while (!try_cmpxchg(&folio->flags, &old, new)) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel