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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE4E5C3DA5D for ; Thu, 25 Jul 2024 16:18:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 26AF76B0083; Thu, 25 Jul 2024 12:18:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 21AA06B0085; Thu, 25 Jul 2024 12:18:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0BB7E6B0088; Thu, 25 Jul 2024 12:18:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E1E5F6B0083 for ; Thu, 25 Jul 2024 12:18:48 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 83CB01212EA for ; Thu, 25 Jul 2024 16:18:48 +0000 (UTC) X-FDA: 82378783536.02.ACED496 Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by imf02.hostedemail.com (Postfix) with ESMTP id B2C578001D for ; Thu, 25 Jul 2024 16:18:46 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ahhzJfAE; spf=pass (imf02.hostedemail.com: domain of fvdl@google.com designates 209.85.167.180 as permitted sender) smtp.mailfrom=fvdl@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721924288; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=taWGaT3w4wOQQ018sVYuoJ2OTMdIrOZ4X59IynnsK/0=; b=vTWQKX2o2Ee0pw0nClQROO/AZwjl7BxOm6qOzsxGZ/8cDZgzYPKeOjYhhSGBLwT7Sg85gV BiH4KI2sd+imJi7hGorDggAT45vsyPQNLAp7N2L3GHn4+BKOCWIgenXwwrmtw6Uh4WWpZ8 ET2mJX2/EoaZWnKPmtdsMAeNADSyZk4= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=ahhzJfAE; spf=pass (imf02.hostedemail.com: domain of fvdl@google.com designates 209.85.167.180 as permitted sender) smtp.mailfrom=fvdl@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721924288; a=rsa-sha256; cv=none; b=LdoqOIYgjIWLqYTAgNZAy+P+kcAepYOLZWFwixYI9h4hlyN9pY5c9y9sabBxcwTVWtgp5C dLlFAnGjnyF0VS7tQ99Id/+LulSYDz7SH2Rk06VWyJGrh6rnml6JWK5aHmVVOgI3B8c0Q1 wNd3SiMhHw/F5mahWD+ULiPheSYDIoI= Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-3d6301e7279so18903b6e.3 for ; Thu, 25 Jul 2024 09:18:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1721924325; x=1722529125; darn=kvack.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=taWGaT3w4wOQQ018sVYuoJ2OTMdIrOZ4X59IynnsK/0=; b=ahhzJfAErV8+owOItroitX1BMYwFo5c3LjDxhDh29wsyspHIFpnQy2IgOQod1xYJsF DLUahNiioAcxE5wuuFyFNx16XMbYRVRaO9px/dYxoi+WN2opQxp7jK6nP6NFrIcDyMpV Xx8irsnjpwuDeWv5Di4eTd1XyuqQbxSmH3gs/MMorHtwXUo9uxx29sY3K7Sntg8zd3Xb yflLyACTe4NbRYMpqFoO3vS9z+crhHe6NTanrOZdpQuf81sOW2QyWmY3Ahj14ao14d38 nQWTNmL1Uupm/kDxaCQ9rED6+ygCbBHgt6uYqi5xDX9A83AcfCB2Th/utmnWcFvREwWd n+Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721924325; x=1722529125; 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=taWGaT3w4wOQQ018sVYuoJ2OTMdIrOZ4X59IynnsK/0=; b=QzX+wQnUAnnYdF8u24k1sBwXZtu9rJ6lOWqo6FqSMpwTixSAUcUQ7VELkUnWvhOSRA xiUyOAtLThvEF4w3wohUZHjc6ld6xA7OjqJitYfnovt0/yhKYT52Ot04i4aSwlQxbwwC GEu+P5mPpoNb6IlcyHDKvYwUcyv9TRBoIihfUK+q399SmOEyEOXA3oaMa5qsusxVjqg/ rxYAEU6pqAwc6Lz2Uuz+Waie1Fe2WdK3eTDZujqQfnc6ekhSImrwV4qOt1K36XhOQHiI pJIC7qePR/UZf35pSd4GRCOrILW1CqO43I9IGEo3BlBZ/Sp2fR6mVIojVk3ZbYcHHxjR /3Fw== X-Gm-Message-State: AOJu0YyPuZuuznb9UlQRPVl/8QZF9u5zfIgqzhhP15kYOwUydtdC099/ czVByrgvkz2ByOYnCGLsXYM5wVbZmw7CrVfEFa2HfkhuUd/juJdfhp2OuTyi8TRwbRH+bRiGerj 07iwai2b2TNnIfQEgsp8+GJfJY91P2/We8MhW X-Google-Smtp-Source: AGHT+IHLEzcxxVMZcmdDCRzakueRTDgXzXsCz/LjKhHPcGx2OqMU6KMBDb/YEtnUeQoaDD0UsCJyYEHM1CsawT9LBW0= X-Received: by 2002:a05:6808:19aa:b0:3d9:243a:7ae8 with SMTP id 5614622812f47-3db141b3a98mr3570225b6e.39.1721924325226; Thu, 25 Jul 2024 09:18:45 -0700 (PDT) MIME-Version: 1.0 References: <20240709163053.2514760-1-fvdl@google.com> <20240724124845.614c03ad39f8af3729cebee6@linux-foundation.org> In-Reply-To: <20240724124845.614c03ad39f8af3729cebee6@linux-foundation.org> From: Frank van der Linden Date: Thu, 25 Jul 2024 09:18:33 -0700 Message-ID: Subject: Re: [PATCH] mm/cma: export total and free number of pages for CMA areas To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: qy7xwicc1frorufjyugxiaciwgyh8anw X-Rspam-User: X-Rspamd-Queue-Id: B2C578001D X-Rspamd-Server: rspam02 X-HE-Tag: 1721924326-490144 X-HE-Meta: U2FsdGVkX1+462zyAIqEkO15M+QhY+87CL69NwmeS9MUjOVq7dJEzhBHa/8H2IHDIjfrbtSNgoSdibKR9RbEEE+S3xKcGqMH9Hk/gMrpoRzF72Trl0/SM8Sl0BiXqWshnRmI9t/xW9OW3s0EQgbEfYm6yw0e1UATgrS3oqiCBvTX7VD4bCCR9WMveD5c0kBM/F2yX/vLu5le1YGP4HXdXuU0n4M/favyVYIQtK4Z0HCdYYoJ8Y1gZT+ltd+NnNW8hG+3mYdJ650vrCiJSZ4kgxPuh6zpPkwACLr+31lG3wmFuDZpPsE40BdtmKWn7eXZFYZQivSJY/WhpAFJ8VsZgugvs5p2doUkyTHFFMPDwOe4g78qe3LAiru3Sm4WZI8apBI27UfwWZ7BKaQEIRl6u5+dcMDr0fPl8MuC/VmYYPielLAMPRzmYeH+JRkwREuo7ilQBUFAetSx5UEHg6yox5BTkh7WZg6DA19v8lIBEmXH5xy25L3JHDTmtXSw06IVKiGnQYH2nHvQw9egiIxXJkEgbkAp1lCfgXM0QDjHfCTbr3KH6KZmHKDyvi+OpJXYh5QAnt4OG+wWy/GzCZLv9yBgDFR/6HUKh9FwnRn7KZlWDWsEM4xeKIFr2lS3ZCG4RnlUfdnVuWBcVPwhba6r8JzkWrV1xHFEeoZcf5ttSUyulsm4ogca8u+JEA3YdcxcHeWzHkCDBpXu3H3MjjTzedcCBv3dcljJNGc2f+1VX1r8isTOerzxBMgo10f+DPU9J/ppDvFwkHU5Oe1HRc8qC0IY9olDkZ65kzoBotJBaq/xgmRUlrBc2U4xGw61mt0iHnk5YxbAD96j/KwDCeFEbCGLwj+Z+Ky3sUubMXWPlFf2ndOdrkmhh7hybCpDV2u1ufel0FDKYo4Z8OpVrrulbw4x+hSBQEYPi73qNAN7bWcHVX/jF/wVWyOsBtQx+/FSK56KBMAS7kWBmlgcY1O 9dLKSsm7 oE81wSFP1LwIRSEn1WdYUPg0ZIizhPuGK+YVO9t5ZasdZ7ZIAIZBjfxHt59vmgh0bgqUqH9/JGrIqrX7h6p/8blbfwGqHatDzS1uR2IDV9PPBAmMjOfVzASWiYlshkJwMyjU38QI/mdKU8QvvemRxHLkB1mvlkqef2ioBSuVlCanfXWYF+fmL8GsH6V/WgotPzqWYPnBU7KVeiYKRQ5IPDA5oel5vDW0tMfOsVIKnkU/0ndWgOUiz2U4D4YyQSyYimWO+2DEpbujd7FwcheKTtdIgIA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000078, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Wed, Jul 24, 2024 at 12:49=E2=80=AFPM Andrew Morton wrote: > > On Tue, 9 Jul 2024 16:30:53 +0000 Frank van der Linden = wrote: > > > In addition to the number of allocations and releases, system > > management software may like to be aware of the size of CMA > > areas, and how many pages are available in it. This information > > is currently not available, so export it in total_page and > > available_pages, respectively. > > > > The name 'available_pages' was picked over 'free_pages' because > > 'free' implies that the pages are unused. But they might not > > be, they just haven't been used by cma_alloc > > > > The number of available pages is tracked regardless of > > CONFIG_CMA_SYSFS, allowing for a few minor shortcuts in > > the code, avoiding bitmap operations. > > > > ... > > > > @@ -382,7 +383,7 @@ static void cma_debug_show_areas(struct cma *cma) > > { > > unsigned long next_zero_bit, next_set_bit, nr_zero; > > unsigned long start =3D 0; > > - unsigned long nr_part, nr_total =3D 0; > > + unsigned long nr_part; > > unsigned long nbits =3D cma_bitmap_maxno(cma); > > > > spin_lock_irq(&cma->lock); > > @@ -394,12 +395,12 @@ static void cma_debug_show_areas(struct cma *cma) > > next_set_bit =3D find_next_bit(cma->bitmap, nbits, next_z= ero_bit); > > nr_zero =3D next_set_bit - next_zero_bit; > > nr_part =3D nr_zero << cma->order_per_bit; > > - pr_cont("%s%lu@%lu", nr_total ? "+" : "", nr_part, > > + pr_cont("%s%lu@%lu", start ? "+" : "", nr_part, > > next_zero_bit); > > - nr_total +=3D nr_part; > > start =3D next_zero_bit + nr_zero; > > } > > Can you please explain the above change? Sure - there's no need anymore to keep a count of available pages for the debug output, since that's already tracked in the available_count field. So, 'nr_total' can be removed. But you still need to check for this being the first instance of the loop, so use 'start' for that instead. > > > - pr_cont("=3D> %lu free of %lu total pages\n", nr_total, cma->coun= t); > > + pr_cont("=3D> %lu free of %lu total pages\n", cma->available_coun= t, > > + cma->count); > > spin_unlock_irq(&cma->lock); > > } > > > > @@ -446,6 +447,10 @@ struct page *cma_alloc(struct cma *cma, unsigned l= ong count, > > > > for (;;) { > > spin_lock_irq(&cma->lock); > > + if (count > cma->available_count) { > > Right here would be a nice place for a comment? > Yes, I'll add one. > > + spin_unlock_irq(&cma->lock); > > + break; > > + } > > bitmap_no =3D bitmap_find_next_zero_area_off(cma->bitmap, > > bitmap_maxno, start, bitmap_count, mask, > > offset); > I'll re-send a v2 with some Cc: lines added. Thanks! - Frank