Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6363289rdb; Mon, 1 Jan 2024 21:50:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHCc9Be97VPDvX1NAVdFULlCy1qAsgUDuwIajo9S986Ahm/kvwBp6RO5mK6z1+hr8K1hrFQ X-Received: by 2002:a17:906:7381:b0:a27:59a1:595f with SMTP id f1-20020a170906738100b00a2759a1595fmr2672669ejl.180.1704174639444; Mon, 01 Jan 2024 21:50:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704174639; cv=none; d=google.com; s=arc-20160816; b=ezxlX3kmYCFkMoJit3815AleQE2HAomzE0qRUte8t/BneHUAfUsWKE6w0Bc6h4t6C6 YwUT/fVO04o+53aOxpXXu8+JhowbxjK5iv18SHA7H9SaJExfXVfaaPp+lYNp6OR3N4at CAtLoNkzkFNgD6mg4FtsqCSxQ5RT5g5VVjIhAkCR9xzN/JARmeWsiZ57SJd67HEV9Fw3 LTpABjLtrheurwUMolsS6MGa24LnZbrqsaPV5reQqHJaB2z/ljCW+n2vVQfL7wfk5p1O x1TosoVwF5auj1SedXOvQiDDEQOhabVy53qVLn/Lh98qVoItbpMXAuxZRRiMsBGeFLyU jbaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Eo66bPCJZwsfoyBeR7AxEooHw9Y9qb4nCq2SNMlkiOs=; fh=jm1A5VovuBtoi39WdeV8lAli9KhTR3pK7ovFZuO4if8=; b=Xl5MOlJ0uYZEllLecfJuvJNhTbCujZJt4OF30IWN/h37BT+60deIm62Ol9Maj1cBI7 425imd89n/BDDsaQdA5sWeK4k4EEq5T0zmGs3Gprdmw8mw4b2b/LkyKt+0w/hY5HHZF9 2MtjMM7o0+3Cq1q2k41vudEyKD8dYx88h7Io5poORzGWS75DJvHoavpX0B6ESYxGEaXi MOT2NTC9naJGR6oVFdwPo0thFq3XIOalrlmUU4PNh1pghUrjdKKIIXv4MPSQX/ePfQXb LSL+OSHnAnGwEJhtil5wvcnAw3mTjFrFAq1vWygtlAEmh79hiX8J1bNdqYpnx42zJ+JC dHXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cHW7s4pi; spf=pass (google.com: domain of linux-kernel+bounces-14063-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14063-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id l23-20020a170907915700b00a23b4407b54si10272137ejs.346.2024.01.01.21.50.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jan 2024 21:50:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14063-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cHW7s4pi; spf=pass (google.com: domain of linux-kernel+bounces-14063-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14063-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 351A81F21A3F for ; Tue, 2 Jan 2024 05:50:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CFC132594; Tue, 2 Jan 2024 05:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cHW7s4pi" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 907F9256D for ; Tue, 2 Jan 2024 05:50:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f44.google.com with SMTP id 2adb3069b0e04-50e835800adso5161184e87.0 for ; Mon, 01 Jan 2024 21:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704174628; x=1704779428; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Eo66bPCJZwsfoyBeR7AxEooHw9Y9qb4nCq2SNMlkiOs=; b=cHW7s4piqtcsVmCNh3H1NHZ1Ai28x+pRqgAdMkzxCsh7QBdTaKJx/pfLFi5As+FQRt 8f4U/k8KgIMasAezBJHvj5MFunQwCfa+8S4+qG/L6o4Vc9/tvoumYRo/fi2TfPKSuNNy MWoh/6AhQVKkMtM6YO4FY/Vrm3RWvKxb7OXzi6sHvSgiU0nmQLp2Dw7detx5rVxIFFzb S8EZUaEfGY7OKIR/BzE/uPXQKCbyDXmV3N0J3jsygTt+puvZiyF2V53U1flG+6x8kK9m W3Lb3ju8eEQiuzRh9RZAcBDAzEtZGgoNYIryMN7MB7sYOB7yeONshWDYjMIloJstfY4+ 8aDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704174628; x=1704779428; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Eo66bPCJZwsfoyBeR7AxEooHw9Y9qb4nCq2SNMlkiOs=; b=iIPqsWa53kcxbl6fo3JXQaaoKClFeQFkHehCyd6BQ05FM/yZelX/QrWUmpLWxd32cP 41rYt9xzMG7y+8q5wcdkqreU25tAh+MP9EomgHC4u+77trD+XZHcuf2FZUaSgoK2BM/t AgkXOwW1v+EZcZKm4gSvA3Nkq2HbDORs03Cxfe8TUzE+HCX1PutlsG2+FOWTIRCJlano S0X+7W3HF+Evq2CwqE59EVAky6E3FPcqnt2mOlpJkQF9Vy1trAuHWKtFYSCSJBqQk64H teVxTIQ/sEFQI8TkKf/qsKzhX44WyTZqWIhrvtd8wNkXBqXs2ac8yzqi3RFF697fIyPh 2ZkA== X-Gm-Message-State: AOJu0YzuJ1FlM6O/c1qlDO+HbqJM5/ukr9fEB1rZjpEdZDg2VHgz4HPz bpfpWtDHKX3hCz5W1amf+bynX6zqp/m9dIeSiWE= X-Received: by 2002:a05:6512:3f1f:b0:50e:8762:3c0 with SMTP id y31-20020a0565123f1f00b0050e876203c0mr2807772lfa.48.1704174628348; Mon, 01 Jan 2024 21:50:28 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231016071245.2865233-1-zhaoyang.huang@unisoc.com> <20231107172820.GA3745089@cmpxchg.org> <20231229114032.64d5320a97a7c776e10e8acf@linux-foundation.org> In-Reply-To: <20231229114032.64d5320a97a7c776e10e8acf@linux-foundation.org> From: Zhaoyang Huang Date: Tue, 2 Jan 2024 13:50:16 +0800 Message-ID: Subject: Re: [PATCHv6 1/1] mm: optimization on page allocation when CMA enabled To: Andrew Morton Cc: Johannes Weiner , "zhaoyang.huang" , Roman Gushchin , linux-mm@kvack.org, linux-kernel@vger.kernel.org, steve.kang@unisoc.com, Vlastimil Babka , Mel Gorman , Joonsoo Kim Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Dec 30, 2023 at 3:40=E2=80=AFAM Andrew Morton wrote: > > On Wed, 8 Nov 2023 16:55:19 +0800 Zhaoyang Huang wrote: > > > > > +static bool use_cma_first(struct zone *zone, unsigned int order, u= nsigned int alloc_flags) > > > > +{ > > > > + unsigned long watermark; > > > > + bool cma_first =3D false; > > > > + > > > > + watermark =3D wmark_pages(zone, alloc_flags & ALLOC_WMARK_MAS= K); > > > > + /* check if GFP_MOVABLE pass previous zone_watermark_ok via t= he help of CMA */ > > > > + if (zone_watermark_ok(zone, order, watermark, 0, alloc_flags = & (~ALLOC_CMA))) { > > > > + /* > > > > + * Balance movable allocations between regular and CM= A areas by > > > > + * allocating from CMA when over half of the zone's f= ree memory > > > > + * is in the CMA area. > > > > + */ > > ok, thanks for point out. > > Could we simple it like this, which will mis-judge kmalloc within > > ioctl as GFP_USER. I think it is ok as it is rare > > if (current_is_kswapd() || !current->mm) > > gfp_flags =3D GFP_KERNEL; > > else > > gfp_flags =3D GFP_USER; > > free_pages =3D zone_page_state(zone, NR_FREE_PAGES); > > free_pages -=3D zone->lowmem_reserve[gfp_zone(gfp_flags)]; > > free_pages -=3D wmark_pages(zone, alloc_flags & ALLOC_WMARK= _MASK); > > cma_first =3D free_pages > zone_page_state(zone, NR_FREE_PA= GES) / 2); > > > > This went all quiet. Do we feel that "mm: optimization on page > allocation when CMA enabled" should be merged as-is, or dropped in the > expectation that something based on Johannes's suggestion will be > developed? I just establish a v6.6 environment and will provide comparison results with and without the patch >