Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2437769rwd; Sun, 21 May 2023 21:30:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ40HTsneWLpxyDEf5LMS/eWO6RonFNkrEJZzmEC1KYcs3puKUJXtUeCDQPrf+pTNNHtlLKc X-Received: by 2002:a05:6a20:394e:b0:103:e813:77a1 with SMTP id r14-20020a056a20394e00b00103e81377a1mr12558819pzg.15.1684729851534; Sun, 21 May 2023 21:30:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684729851; cv=none; d=google.com; s=arc-20160816; b=sjti02eXR3beWlqnQAi2ety13wdd4dOZPdJwMxtA2WYCIbqEwZUkdwKgvix2BpyjSX PDidZ69OI6B5hoJflfqGY0gNef93itItElu62TrDZ2GlupMqUSphvcO52g8r0fOuQVbV NhiF0E/2B2KPcJWGM6GSfO952Iq+qVGROFUMGRJYHs1/mjy4VaEWAQwef1B33CpFPUWg 4jyHb8BC1yvisfFHlR+gElHITNrZKKiOzVR9335SJPaEyTn0WhxKlZheZ/y6elAiGtqq 2NzJwpv91JHDKyVktyOJceLMmZPG3vJbuYYOU7a/+x58Yu/+PrLg0YVc+QJjCZhyKtk+ Fp7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0/snmGSuIpgVM93/uzUSc6arNhFDyaJVOF59ybeoIhM=; b=lKxl5FKgx3nbq3l1auNpUMHyEfd78PNVsObVG+BG9VmgsT2YVcggtdogEaYlCmXJeM 0QvnMVT4gy+LSpUYGinchJSkHl6oeUjt+iFPIiH9S4+rg4cAkO2dk4ctKzwOHZ9Kfh41 m+e1eBIqRtjq/DIVyVidtl85kWC7WYri2qRCuBJA/PaJ5yp1WM4dabSPRTUflo8+KvJX s0hBh2651UuoCBSdmiTdChZVbbzO8wwY1uL6AUw+Q8cGYt/OKzYDXjsl1N8IS9VqUoeS Tx37/BG5SY2STk1LluUVKhNxF/O3IFUFxsmr+sET2dqOC+U6yjvy0HD+jLlTYFEHWMKW bbxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=rtEMEeQl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u12-20020a63790c000000b005303a7ca052si4381050pgc.491.2023.05.21.21.30.37; Sun, 21 May 2023 21:30:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=rtEMEeQl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229728AbjEVEIV (ORCPT + 99 others); Mon, 22 May 2023 00:08:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229722AbjEVEIT (ORCPT ); Mon, 22 May 2023 00:08:19 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F5A4DB for ; Sun, 21 May 2023 21:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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=0/snmGSuIpgVM93/uzUSc6arNhFDyaJVOF59ybeoIhM=; b=rtEMEeQlFvw19x+165/zWMjt+1 4pXC2vcvKDZG1H6x8xWBBAbhNyDk8RSnjUivwdVgbtYpSIpiOS9FZ4I3u/pzrl8FzWxfi9gVSNuvw 2D+qNY9EMovdN6SfvIfToN3/pp0ZvzP9x9frTSGbNOEh05pNp9LRgvWMwXgK1S3YNWkM/taSVfdhI 5ioXaxvWspeLaHFIGpcPtXVNjZ+WR2I7fCyRVHitOknBub7dr8SY0AYyjjwdqAzbbRfcHXqpU6INr q4wB0b36VSOfDIDzqoKwMhIjijC6ohcO5DaCYisXfNUq6GTZzo4apCxjFVCGjGEQU9g3mmZ+J95aX UrMxiioA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1q0wps-008kKO-1i; Mon, 22 May 2023 04:07:52 +0000 Date: Mon, 22 May 2023 05:07:52 +0100 From: Matthew Wilcox To: "zhaoyang.huang" Cc: Andrew Morton , Minchan Kim , Joonsoo Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhaoyang Huang , ke.wang@unisoc.com Subject: Re: [PATCHv3] mm: skip CMA pages when they are not available Message-ID: References: <1684724882-22266-1-git-send-email-zhaoyang.huang@unisoc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1684724882-22266-1-git-send-email-zhaoyang.huang@unisoc.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 22, 2023 at 11:08:02AM +0800, zhaoyang.huang wrote: > +static bool skip_cma(struct page *page, struct scan_control *sc) > +{ > + if (!current_is_kswapd() && gfp_migratetype(sc->gfp_mask) != MIGRATE_MOVABLE > + && get_pageblock_migratetype(page) == MIGRATE_CMA) > + return true; Putting the 'return' at the same level of indentation as the second half of the conditional is wrong. It confuses the reader. Also, the && needs to go at the end of the line not the beginning (read the codingstyle documentation!) Also there's no good reason to use such long lines. ie do this instead: if (!current_is_kswapd() && gfp_migratetype(sc->gfp_mask) != MIGRATE_MOVABLE && get_pageblock_migratetype(page) == MIGRATE_CMA) return true; if you prefer, this style of indent is also acceptable: if (!current_is_kswapd() && gfp_migratetype(sc->gfp_mask) != MIGRATE_MOVABLE && get_pageblock_migratetype(page) == MIGRATE_CMA) return true; > @@ -2225,10 +2242,12 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan, > unsigned long nr_skipped[MAX_NR_ZONES] = { 0, }; > unsigned long skipped = 0; > unsigned long scan, total_scan, nr_pages; > + struct page *page; No, don't do this. > LIST_HEAD(folios_skipped); > > total_scan = 0; > scan = 0; > + Don't add this completely unrelated whitespace change either. > while (scan < nr_to_scan && !list_empty(src)) { > struct list_head *move_to = src; > struct folio *folio; > @@ -2239,12 +2258,14 @@ static unsigned long isolate_lru_folios(unsigned long nr_to_scan, > nr_pages = folio_nr_pages(folio); > total_scan += nr_pages; > > - if (folio_zonenum(folio) > sc->reclaim_idx) { > + page = &folio->page; > + > + if (folio_zonenum(folio) > sc->reclaim_idx > + || skip_cma(page, sc)) { Again, this is not where the || goes. And skip_cma() should take a folio, not a page. It's unreasonable to ask you to convert get_pageblock_migratetype(), get_pfnblock_flags_mask(), __get_pfnblock_flags_mask(), etc to use a folio (... although someone looking for a project could do that ...). Instead, you should do the folio->page conversion inside skip_cma(). > nr_skipped[folio_zonenum(folio)] += nr_pages; > move_to = &folios_skipped; > goto move; > } > - No unnecessary whitespace changes.