Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1412098pxf; Fri, 19 Mar 2021 06:47:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQxMpoUcxOty9+vd2nFh4U1T0wqvZ0YtgS3Tfp51WIG4Pv7jqGHxDa6NmgXESNOuhdV34c X-Received: by 2002:a17:906:9714:: with SMTP id k20mr4404457ejx.519.1616161679475; Fri, 19 Mar 2021 06:47:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616161679; cv=none; d=google.com; s=arc-20160816; b=Rwv/CMHAbZCORZ3E/V+kqiXkZKB0hUA0dTKrt4CpJE8HevnIQBGlO7Y0BmEWijWx1h XteW8HBGJd/DRpr7sk0tVgQUq68ZvHV1jWlyaJ4TYbtjQ1ej1ITvXx5dez8b/aQb5vFR tRSndM6CbpBeUR/p4KkO823hxQCp373BOr/IxcsvIztg5Z3b9kv2WYdnDZWQtRa2z6o5 qC7krOHN09sH9Xhbi7iKUdl9b3UpfgLWU2gsWFl/eba/oRN3oZc2udoBy+Wgwqkor/Gb db4y8u+yUk1P+JYCA8pYq8MOMGkp6HCPDOC2OLyMt99fNKVFdUYL6QeZv/noBSVUh5Hs cosw== 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=zm6BLtowGVk3+ISKouC1h9zvIkxos89pb8oEnL5NIS8=; b=D7QwLsozNnaXc5iotVOsf7wIOjgVu2uxKR1mfJYkAFw/7El4eTQdjAqnBEsRmA/4Ki TA3F/3R3qmFdY6/oFEP3bbi6D0JqeX5izR6fbFbKNmPyMleeh7QANALOuzRJp+xAtzd5 RNWdadyGin0nqT7dPn/B6t77AvNzpcURy7QeW2J2Hj8xRbtGCphaev7Oc0qUEuhzdXm8 WTj7RuHziNHz2/wnMHLqWF2EYWKmPH8MQoYB7iJZzk+Us35lOM1M15Uew3QsZUTxe41I bNwDdJxWfr3luU2kDa0GkKz0mIEK2iGnNvWaYyMCI/LB+343QTjNfvPQ5uN+wY6eAlhu utCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="d/nHmMhj"; 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 n16si4086009edw.216.2021.03.19.06.47.36; Fri, 19 Mar 2021 06:47:59 -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="d/nHmMhj"; 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 S229937AbhCSNqW (ORCPT + 99 others); Fri, 19 Mar 2021 09:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230081AbhCSNqA (ORCPT ); Fri, 19 Mar 2021 09:46:00 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF303C06174A; Fri, 19 Mar 2021 06:45:59 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id f3so1736398lfu.5; Fri, 19 Mar 2021 06:45:59 -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=zm6BLtowGVk3+ISKouC1h9zvIkxos89pb8oEnL5NIS8=; b=d/nHmMhjTTMvsGTzLwH4k3vaY1L3wQH6aDBlMAsoOo40wtx7L3DTiTQ/eY7Y0rybbw QsiroprLBqmESHuM1Jv7zB8A6PswfeUGK0dbmGStvfK1HtPFQLv6SM6TCJXgDjXsrAk0 gQVKBfDiH+oiELc/fF1ROH/D2uG0mPeA5WmrOGttGJJ+hkpDXfsTd2s/nnhl4lidzz4F cmPDQ2F8XJK1gZzyJPRGtzcJJYoUUefhN2/b38kiMvoVOvhXjX/yFhqFhipEC4lhVI09 GN2IYAZVH+6m2pzsuc9RUpQFEU8dW+TGzK/twyqwJWQuWmMANe4u6G4ZV4/Knl2MMw9G gOKA== 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=zm6BLtowGVk3+ISKouC1h9zvIkxos89pb8oEnL5NIS8=; b=jaC9edaB6b1xtVqTkM8pT2/BVp7H5vO8sBDc/B9ma4OrrSJkIPeAcfy8QPm+aqCNRT RrMT/guxx5eRsDOfRgrOqHLdrsWxsfSnxzQ4dHbsSI7V/CTtuV9/WfiV43WJJdUX7XoS gHOtjOlUKuP/O5cIYQCg7h7bwkQOBrSY6fsLrw6TLgpWzHFyi1VzgTkY/lLT766SEYaZ b/4yoiKb5wnBGSzjVYVPgQ0e9J4mFbN0QvrGyAeA0j3gFzn8/eKkoFtRRx/mDuwfQ7Jr cwni9Jzqlwl7MmutV5cj6JPJ+YbKsHvlWhuEjvxDqn8L97fmlAR8aMPIFsLyI51ShbJd 6c1g== X-Gm-Message-State: AOAM5328vLJ4LK+IE/FpMuRWWw0bMJzwCTVQcv0ozHnsoKYUlS3HTfbG 6pRW5M2zSsiCogrbMUnN3WrQQYVqGhw= X-Received: by 2002:ac2:5149:: with SMTP id q9mr843384lfd.619.1616161558226; Fri, 19 Mar 2021 06:45:58 -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 m22sm640702lfa.170.2021.03.19.06.45.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Mar 2021 06:45:57 -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: <8d7ae527-e0ff-6fa9-7ba3-899a75abc3fa@gmail.com> Date: Fri, 19 Mar 2021 16:45:57 +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 16:39, Dmitry Osipenko пишет: > 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. > Actually, the counter should be u64 in order not to worry about overflow.