From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932989AbbLWQI7 (ORCPT ); Wed, 23 Dec 2015 11:08:59 -0500 Received: from mail-yk0-f177.google.com ([209.85.160.177]:36799 "EHLO mail-yk0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751536AbbLWQIz (ORCPT ); Wed, 23 Dec 2015 11:08:55 -0500 Date: Wed, 23 Dec 2015 11:08:54 -0500 From: Tejun Heo To: serge.hallyn@ubuntu.com Cc: linux-kernel@vger.kernel.org, adityakali@google.com, linux-api@vger.kernel.org, containers@lists.linux-foundation.org, cgroups@vger.kernel.org, lxc-devel@lists.linuxcontainers.org, akpm@linux-foundation.org, ebiederm@xmission.com, gregkh@linuxfoundation.org, lizefan@huawei.com, hannes@cmpxchg.org, "Serge E. Hallyn" Subject: Re: [PATCH 1/8] kernfs: Add API to generate relative kernfs path Message-ID: <20151223160854.GF5003@mtj.duckdns.org> References: <1450844609-9194-1-git-send-email-serge.hallyn@ubuntu.com> <1450844609-9194-2-git-send-email-serge.hallyn@ubuntu.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1450844609-9194-2-git-send-email-serge.hallyn@ubuntu.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, Serge. On Tue, Dec 22, 2015 at 10:23:22PM -0600, serge.hallyn@ubuntu.com wrote: > @@ -164,18 +286,39 @@ void pr_cont_kernfs_name(struct kernfs_node *kn) > void pr_cont_kernfs_path(struct kernfs_node *kn) > { > unsigned long flags; > - char *p; > + char *p = NULL; > + int sz1, sz2; > > spin_lock_irqsave(&kernfs_rename_lock, flags); > > - p = kernfs_path_locked(kn, kernfs_pr_cont_buf, > - sizeof(kernfs_pr_cont_buf)); > - if (p) > - pr_cont("%s", p); > - else > - pr_cont(""); > + sz1 = kernfs_path_from_node_locked(kn, NULL, kernfs_pr_cont_buf, > + sizeof(kernfs_pr_cont_buf)); > + if (sz1 < 0) { > + pr_cont("(error)"); > + goto out; > + } > + > + if (sz1 < sizeof(kernfs_pr_cont_buf)) { > + pr_cont("%s", kernfs_pr_cont_buf); > + goto out; > + } > + > + p = kmalloc(sz1 + 1, GFP_NOFS); We can't do GFP_NOFS allocation while holding a spinlock and we don't want to do atomic allocation here either. I think it'd be best to keep using the static buffer. Thanks. -- tejun From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tejun Heo Subject: Re: [PATCH 1/8] kernfs: Add API to generate relative kernfs path Date: Wed, 23 Dec 2015 11:08:54 -0500 Message-ID: <20151223160854.GF5003@mtj.duckdns.org> References: <1450844609-9194-1-git-send-email-serge.hallyn@ubuntu.com> <1450844609-9194-2-git-send-email-serge.hallyn@ubuntu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1450844609-9194-2-git-send-email-serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org> Sender: linux-api-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, adityakali-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org, linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, lxc-devel-cunTk1MwBs9qMoObBWhMNEqPaTDuhLve2LY78lusg7I@public.gmane.org, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org, gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org, lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org, hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org, "Serge E. Hallyn" List-Id: linux-api@vger.kernel.org Hello, Serge. On Tue, Dec 22, 2015 at 10:23:22PM -0600, serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org wrote: > @@ -164,18 +286,39 @@ void pr_cont_kernfs_name(struct kernfs_node *kn) > void pr_cont_kernfs_path(struct kernfs_node *kn) > { > unsigned long flags; > - char *p; > + char *p = NULL; > + int sz1, sz2; > > spin_lock_irqsave(&kernfs_rename_lock, flags); > > - p = kernfs_path_locked(kn, kernfs_pr_cont_buf, > - sizeof(kernfs_pr_cont_buf)); > - if (p) > - pr_cont("%s", p); > - else > - pr_cont(""); > + sz1 = kernfs_path_from_node_locked(kn, NULL, kernfs_pr_cont_buf, > + sizeof(kernfs_pr_cont_buf)); > + if (sz1 < 0) { > + pr_cont("(error)"); > + goto out; > + } > + > + if (sz1 < sizeof(kernfs_pr_cont_buf)) { > + pr_cont("%s", kernfs_pr_cont_buf); > + goto out; > + } > + > + p = kmalloc(sz1 + 1, GFP_NOFS); We can't do GFP_NOFS allocation while holding a spinlock and we don't want to do atomic allocation here either. I think it'd be best to keep using the static buffer. Thanks. -- tejun