Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp221701ybh; Tue, 10 Mar 2020 23:26:02 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvjL2KbzJ1k2CI/pt3HqZhtRzfxYpY8X5vBuJkzkoZTpy7tO3+q2vyX6Odvs23/DKtXVhk+ X-Received: by 2002:a9d:649a:: with SMTP id g26mr1167709otl.266.1583907962615; Tue, 10 Mar 2020 23:26:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583907962; cv=none; d=google.com; s=arc-20160816; b=abeECrS4pF+O3Sn19zRitKRvFK/F6+PFARDF6KM1BieLCdNXFzq3N5yVelbY8oZwe8 zJP8+IZe6XMVgEXX73EZM0FCVk1FeFlbyLPMos8yfLtM2/LPfusr7p/LAlmDS38Y8dZD AK9+4YofKlUz5Ckhu/pc5tpsIG9LStzTm/2lDgLxQL2u2qJlMggRh0ZU2sx5UvM4Kdjs NhpA51vPweSxURiMo3kJQOmqrr16xpX5mTqs9sVvFAF7u1CpVgOpk5HXuPi+3Ha93A4m XXqwVk8Q+G1Tv1BDUOtNHbMKy3Ix9bLx1uFaq2mgK0WGxabrMbwL5qi5e5zua1UAwba5 ipsQ== 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=bt1O8uM5G8pXH1MHWG9pCoJ7EMImXZ7wY9eLxbsFLdA=; b=NKzJn6BcFXPobU0J5AZ4i6rqEPNVaCdhLO4R4cq4e0F62F5nM1XSDnzceVOcm0iTrh HtrynU7L//NPxzJwZbDDDPFdru0aCMw+ZaL9Lv0b1LFeQZ3qJvloxzuCkyuckIICnV+B Y6lA3lXyUQems+eKBqfJiyl0IF0M54te+GlRqU2b152RigVEjINv6UEq3Qlf2I9Gu1FK 6oIn0BCT06wvo3I9AwUXoFRysKAZpmaVXtbptQ0Jg8JVmRDMxlE553Ozr+ViOLnP7Xql Op0AdTwRz/VUjUiM6mSTqpXw06wlJqx31Q9uWNSgK5dmILI7nxAQGSD/s5ohx+Op+a12 EuUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=LgPW57tz; 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 v21si263264oic.163.2020.03.10.23.25.49; Tue, 10 Mar 2020 23:26:02 -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=LgPW57tz; 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 S1728120AbgCKGZP (ORCPT + 99 others); Wed, 11 Mar 2020 02:25:15 -0400 Received: from mail-pj1-f65.google.com ([209.85.216.65]:52396 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725976AbgCKGZP (ORCPT ); Wed, 11 Mar 2020 02:25:15 -0400 Received: by mail-pj1-f65.google.com with SMTP id f15so454349pjq.2 for ; Tue, 10 Mar 2020 23:25:12 -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=bt1O8uM5G8pXH1MHWG9pCoJ7EMImXZ7wY9eLxbsFLdA=; b=LgPW57tzWWWdp9KgQ0hpT4ZMxdE4CE+5156yW06y5G9NTk8fi4QDfdxtQc38KQTxws +pdsUZ+euQv91pReXuvQheDBUPIY8y09YfuEh8UBcqwPN4Vlmey9i0P9BWMwRYS8xyPF BEX6ZgDvG2KolqPQB0MKqK22ho6OelCf7WccHLduOeiJyF5rWt5F9KHQC8HwwiRG2f5X ZV0Bd2QZ5l8cxJX6C6Svu7mzCbJLs1iVpr78RtAogCcium+Lz0HKKoGHXOFVBSvItQPr xo0k7jRJlC2Nme1PS/2BHqxn9gvzmUmFnYUd02b351r+kp53hpfMWgrxoWIPlXa46/YR 3ghg== 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=bt1O8uM5G8pXH1MHWG9pCoJ7EMImXZ7wY9eLxbsFLdA=; b=VaJTSKGi87ONabVK9ep/EmLEkZm8aTNiG/+GpemJTmVOIioXcM2FMamQhc4c6nYv/W ev+k555BqxCsHslp8isH4ijmfGPvtxvCZLladGX/fkT810B9M94vr+sHQf9SY/W+9ugO V3K1pcr+DJnB0kwlJoXl7QTL6Bs8xmIfqA9HEKLHr0BjvUINKnhgnBIpyvVeQS1gN8oy BpUMdMxTqlYwp2s7rLPIwJc9VYRbfP/DOayXOzowskT61Fc+uKyaetQ/5trjBxd4au8R iCHsX9/i6SE3mf5kbmixPMdsTm+J8s0T4fTsTFIgJikSSV6Snv7dGsO+vNLrRGst8QIH PPMg== X-Gm-Message-State: ANhLgQ3BROwJpYJbchAiyXd+9L/zwmlzsGJcJUc+cradjhbZxIi4j7aP Og7vj0GyZMwrkGSuw1hDDsU= X-Received: by 2002:a17:90a:c301:: with SMTP id g1mr1767437pjt.173.1583907912392; Tue, 10 Mar 2020 23:25:12 -0700 (PDT) Received: from localhost ([2401:fa00:8f:203:5bbb:c872:f2b1:f53b]) by smtp.gmail.com with ESMTPSA id 199sm53153692pfv.81.2020.03.10.23.25.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2020 23:25:11 -0700 (PDT) Date: Wed, 11 Mar 2020 15:25:09 +0900 From: Sergey Senozhatsky To: Sergey Senozhatsky Cc: Jaewon Kim , adobriyan@gmail.com, akpm@linux-foundation.org, labbott@redhat.com, sumit.semwal@linaro.org, minchan@kernel.org, ngupta@vflare.org, 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: <20200311062509.GB83589@google.com> References: <20200311034441.23243-1-jaewon31.kim@samsung.com> <20200311034441.23243-2-jaewon31.kim@samsung.com> <20200311061836.GA83589@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200311061836.GA83589@google.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 15:18), Sergey Senozhatsky wrote: > 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'? Ah. The buffer size is NAME_BUF_SIZE, so should be fine. -ss