Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp217601ybh; Tue, 10 Mar 2020 23:20:16 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt0tGDlgreOOMXP9X4xQVxN+TAzeMiQdeFP1T/yGICrGnHgorEmKGC8qF8PzFy20H3ZS3Pg X-Received: by 2002:a9d:5a09:: with SMTP id v9mr1078461oth.214.1583907616320; Tue, 10 Mar 2020 23:20:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583907616; cv=none; d=google.com; s=arc-20160816; b=Ls2AnApV/dAZ5I7EMe7Q/qb3L/ROg9tkxbRfHvUxKGCCbLeDxWCek4YY/BRFbDvjTO jvL6kAHdcTnXxjFiOJLItUkfdrHTaqEe7j/66edLkiiELU0yKApAjqRpD7Twz8RSQqke sJcrG+VBRreixzkWD8h1l6YNsTn0ndHqgCU/pG5XzzLo1JD8EyrXvxe1PibHq9vaGF9/ +08fvSkk9nT16XMkNGotDowvcD6TXXY7yEWU1QzmcTfCPam7nngDloO77zZRoLhJDqr1 fr2Y6okqQh+XT14s8IABNfbtgKu/ESoj0qKtsG1STylb0mboGn9+cskt7B9GfPVVqDAu 2Zhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1lEpduL7xZKe+1xFm5EOElJ3D+S/whf41wP88yrzLmc=; b=LC5CwXNBJ/5JAw9FborEsmVq6rLy9CwhgDOmeiMtSLZEcJUT2lln4J3bHMORJZDWX8 1uPqgqsmGCh6Qr4ucdJTXYVgJQpAzWeOE4MDMwkMcqc+mmEYg8cIUCBzgWwUkOaLR1LE 9Yn3Qc59BBiIgTCVH1+E0QrgBswgj+r13kLSMFG1UA+cLbC2IDyNmv3bAFUFa01QhOeV kERz/dqnn8l2iTXDPDYOD1GZQKAapZEpHG2dYWDHhlZmCDExdyUh+4QLc7DFyXqc203y ZRryw7VPI/vGkXq4Qab/02K5vwiPr00oifZOlmEVwMDNQZhzuR1FRSqEQybO0DZ/EnbA 1YMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vHdraEU9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id r3si649038otn.55.2020.03.10.23.20.03; Tue, 10 Mar 2020 23:20:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vHdraEU9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728122AbgCKGSk (ORCPT + 99 others); Wed, 11 Mar 2020 02:18:40 -0400 Received: from mail-pj1-f65.google.com ([209.85.216.65]:39956 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725976AbgCKGSk (ORCPT ); Wed, 11 Mar 2020 02:18:40 -0400 Received: by mail-pj1-f65.google.com with SMTP id gv19so464396pjb.5 for ; Tue, 10 Mar 2020 23:18:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=1lEpduL7xZKe+1xFm5EOElJ3D+S/whf41wP88yrzLmc=; b=vHdraEU9oEKRmN/aO1eG26kjWGjH81KxED3NM4nZHoB/x1KrttSyklZ7Gf5jLvxYO9 0M1Cly43XGEEvR6SB0kuk+vzDhVRnx4YM6aosUcb6dgueW6qDthtW86BNmPFgzGzXV7v HdLn6SjhvNJBC8zGztkO4AqiIFy8X/ShovdnTXKEW+m+RhRplbTjCqmnqhp3jf19cil8 CXQ1bcSEQbdG0qdvlHdl5deAf9cc5YJSbhPSpsdumwE+4KKSLICyKyaeyZhwlDPceaRf R/TKunyvDzhfGf9dJ8VQfxJ9m92GP4rEwyfzs7KGLB/xT60TA/DbdLnVxMrVwYS4Go5R nv9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1lEpduL7xZKe+1xFm5EOElJ3D+S/whf41wP88yrzLmc=; b=pWoRaaz1nF5tEfYcaqOEc9yM0Tg9MF28MJWJOzkB2vgfDf74Y3x0LIAOmSHjyIzbDo XpdJjZytzGEX4IgbELynsSrHCd5teLQeNuwAWyUUj+XUXaY+8nq6Z2qgmROBwYDoWODU 8qTZ1vKaFuP+OIp0tLO02v43Bg9NOwvXWo3BhK9+oMxMDMvX8ud/Qdaod8oc0tH8LYFD Z0PaHW4SawfjN3ZFz30OGy9KZ9cpqDYs1R0urnz2tOWwvjv7Lgsp0Bd6X9N/WImXziV3 vO+2W9z1YK/ZksP8H9l34hKRkp/Xr7KNBycQ6JvQigAgj1ha0CsQsZzZkuOOXPyiOYqD JtOw== X-Gm-Message-State: ANhLgQ1zZd58fErkKjkLIfDs9Oc+voHEU0uLXReegNgBabrEYOlvsPvM t3HEacTW85Ob6s7kJ1OELhA= X-Received: by 2002:a17:902:d88d:: with SMTP id b13mr1593323plz.228.1583907519508; Tue, 10 Mar 2020 23:18:39 -0700 (PDT) Received: from localhost ([2401:fa00:8f:203:5bbb:c872:f2b1:f53b]) by smtp.gmail.com with ESMTPSA id gx7sm4180800pjb.16.2020.03.10.23.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2020 23:18:38 -0700 (PDT) Date: Wed, 11 Mar 2020 15:18:36 +0900 From: Sergey Senozhatsky To: Jaewon Kim Cc: adobriyan@gmail.com, akpm@linux-foundation.org, labbott@redhat.com, sumit.semwal@linaro.org, minchan@kernel.org, ngupta@vflare.org, sergey.senozhatsky.work@gmail.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com Subject: Re: [RFC PATCH 1/3] proc/meminfo: introduce extra meminfo Message-ID: <20200311061836.GA83589@google.com> References: <20200311034441.23243-1-jaewon31.kim@samsung.com> <20200311034441.23243-2-jaewon31.kim@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200311034441.23243-2-jaewon31.kim@samsung.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (20/03/11 12:44), Jaewon Kim wrote: [..] > +#define NAME_SIZE 15 > +#define NAME_BUF_SIZE (NAME_SIZE + 2) /* ':' and '\0' */ > + > +struct extra_meminfo { > + struct list_head list; > + atomic_long_t *val; > + int shift_for_page; > + char name[NAME_BUF_SIZE]; > + char name_pad[NAME_BUF_SIZE]; > +}; > + > +int register_extra_meminfo(atomic_long_t *val, int shift, const char *name) > +{ > + struct extra_meminfo *meminfo, *memtemp; > + int len; > + int error = 0; > + > + meminfo = kzalloc(sizeof(*meminfo), GFP_KERNEL); > + if (!meminfo) { > + error = -ENOMEM; > + goto out; > + } > + > + meminfo->val = val; > + meminfo->shift_for_page = shift; > + strncpy(meminfo->name, name, NAME_SIZE); > + len = strlen(meminfo->name); > + meminfo->name[len] = ':'; > + strncpy(meminfo->name_pad, meminfo->name, NAME_BUF_SIZE); What happens if there is no NULL byte among the first NAME_SIZE bytes of passed `name'? [..] > + spin_lock(&meminfo_lock); Does this need to be a spinlock? -ss