Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1406848pxf; Fri, 19 Mar 2021 06:41:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFfqD3Z6Q/obYU88smtHn4aPEmWVMqpXV0AXihEffLWUxOsn1E36Mn4awU8SX5UXXs+cKG X-Received: by 2002:a50:eb8f:: with SMTP id y15mr9615783edr.115.1616161269906; Fri, 19 Mar 2021 06:41:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616161269; cv=none; d=google.com; s=arc-20160816; b=O8ahhcdB/PRY8RvUL582wQYlJq+cY224OM5xK1ZNZ7bYUwqpqU18Jo7DA3U1W6Nd4O 2HUfSPEnOm04lNo6mCk9afogsJhelhleJCofs4HR+sCmChiXR5QMNwIBPMrpCVJs1Tz6 xboIorfI2kScdubQ/iWJ19hYWQ6ln2BSQ7if7dnsPz3490ofm00M7BjGfgIgbleQVDmr 2mdRZ2s4qiX3bOTiAI/zmKZ48IqudURoJ3Rz+aNtcvP81WwlkMWQCNQiX0jfTVBf0E67 dI5M8o6EBFpIcJnBm+mZ8Uu70yi/8qjfovV8CtKCLgAYnnZto5wLNclQRVDaLh99KXeR zzfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:references:cc :to:from:subject:dkim-signature; bh=fyvAl1ud31RwhXT5skBunJKZtf9rGtmbohQtkuhaBSk=; b=aIJOuAcTHd5juLXlRKGb5QodQYKUJLFl+8Nlhni8Eaao7uJMGNrBJ9kvV6WqDuiZ3k xhTS1XNtCzIhzxxYNGnNfdv1efzHccPEUFCVugGflYL+sSiS+Hi88wZy3bw5nYDqfSSb hpk4fYNDR/61XtYpVPfd8umc1SZgL+tAJA1ER/ZvpsSf3HMrp+JFFZ7agLcL2szXkwmo d6C9fc1nUkYm1lITBQ9kgSeEFKrUnK4CE1L1hw9ebHLIKCuVV6rQJH3QJklriJy9yyTw 7Cg7F3PfAJm6irEhbSx6KRdXN4u38pJjEa6id0tLa5TfuMVkmXeMgHy3aYQ7L5uglHOK cALg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FNzLDRJF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dj20si4273314edb.250.2021.03.19.06.40.46; Fri, 19 Mar 2021 06:41:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FNzLDRJF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229926AbhCSNju (ORCPT + 99 others); Fri, 19 Mar 2021 09:39:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbhCSNjo (ORCPT ); Fri, 19 Mar 2021 09:39:44 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EB52C06174A; Fri, 19 Mar 2021 06:39:44 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id q29so9968518lfb.4; Fri, 19 Mar 2021 06:39:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=fyvAl1ud31RwhXT5skBunJKZtf9rGtmbohQtkuhaBSk=; b=FNzLDRJF5VVqujMp6CjY9HXNBHu0oM96hG2vqMHk4LjXWYoy9gq2VMV60K0S/u24dQ oOMN0u/GgBP3DjIT/Gxe6A1f3VcfmYkTcEE31YjwCzy/7uZV197fqAlwMY8sB473bkki 0iMkfzI6kArfHIJk3JckcSG5cG3sYRPSAJw2M+r6FU5McBNCdvWmeDsdfrPZYIyRjawD fIKjiSRUGxUlrxkVoGfoq2afnC5bnIkSRlNf0oD2qWoAT9n89gPa4vR4TdZNVsYWIejJ XZVDDCu0HBTMSB6tPEFCojFMppPix/9RR1seUQQTfL9LoBuH3QH5royapmSAAWhcppxa EwOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=fyvAl1ud31RwhXT5skBunJKZtf9rGtmbohQtkuhaBSk=; b=fezhaCVB9pm1/JlIeIm7xcFZm4h/uk1WXhlrkCV2rhAFDPI/OhmejPWP0a1nF/hkwI lgi6AGq+mG+GUzW5pEFae8gvJTeTqsJ8rOFFI2lERx5eM8ObhBV7j88Ck03mDTrtk/6f QOWabbp80IKauXiaFxmIoB3isIG5cwezM+eA0kkVCIHY5eg+zrtsug5euh3SlDxjpKVc aKmye6wZUeq+Muq3pGH+9GsBq+dQTFOCttugpIdsx2caG5Ww+iCS3yl6BigT+AL3Vkob HH845bFryK3APbQfgk32RWG9Hggvfo7mCLmFcTKPq3MEkB8eK7Y+tazklolBFZjn2HHt aR8A== X-Gm-Message-State: AOAM531jyWnW07TCF9yy76dsTXcyFijCzlEQVdGBLLnPG7QbCPZXo4N+ f/L45pCCoKX+z0j7RX3O19qfml/EPTo= X-Received: by 2002:a19:7504:: with SMTP id y4mr858841lfe.616.1616161182717; Fri, 19 Mar 2021 06:39:42 -0700 (PDT) Received: from [192.168.2.145] (109-252-193-52.dynamic.spd-mgts.ru. [109.252.193.52]) by smtp.googlemail.com with ESMTPSA id d4sm638197lfq.270.2021.03.19.06.39.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Mar 2021 06:39:42 -0700 (PDT) Subject: Re: [PATCH v4] mm: cma: support sysfs From: Dmitry Osipenko To: Minchan Kim , Andrew Morton Cc: linux-mm , LKML , joaodias@google.com, willy@infradead.org, david@redhat.com, surenb@google.com, Greg Kroah-Hartman , John Hubbard , Nicolas Chauvet , "linux-tegra@vger.kernel.org" References: <20210309062333.3216138-1-minchan@kernel.org> Message-ID: Date: Fri, 19 Mar 2021 16:39:41 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 19.03.2021 15:44, Dmitry Osipenko пишет: ... >> #include >> +#include >> + >> +struct cma_stat { >> + spinlock_t lock; >> + /* the number of CMA page successful allocations */ >> + unsigned long nr_pages_succeeded; >> + /* the number of CMA page allocation failures */ >> + unsigned long nr_pages_failed; >> + struct kobject kobj; >> +}; >> >> struct cma { >> unsigned long base_pfn; >> @@ -16,6 +26,9 @@ struct cma { >> struct debugfs_u32_array dfs_bitmap; >> #endif >> char name[CMA_MAX_NAME]; >> +#ifdef CONFIG_CMA_SYSFS >> + struct cma_stat *stat; >> +#endif What is the point of allocating stat dynamically? ... >> +void cma_sysfs_alloc_pages_count(struct cma *cma, size_t count) >> +{ >> + spin_lock(&cma->stat->lock); >> + cma->stat->nr_pages_succeeded += count; >> + spin_unlock(&cma->stat->lock); >> +} >> + >> +void cma_sysfs_fail_pages_count(struct cma *cma, size_t count) >> +{ >> + spin_lock(&cma->stat->lock); >> + cma->stat->nr_pages_failed += count; >> + spin_unlock(&cma->stat->lock); >> +} You could use atomic increment and then locking isn't needed.