From mboxrd@z Thu Jan 1 00:00:00 1970 From: Rui Xiang Subject: Re: [PATCH 1/9] syslog_ns: add syslog_namespace and put/get_syslog_ns Date: Mon, 29 Jul 2013 19:47:02 +0800 Message-ID: <51F65636.6080505@huawei.com> References: <1375065080-26740-1-git-send-email-rui.xiang@huawei.com> <1375065080-26740-2-git-send-email-rui.xiang@huawei.com> <51F6388B.8000308@cn.fujitsu.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <51F6388B.8000308-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Gu Zheng Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, serge.hallyn-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, libo.chen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org, akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org, ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org List-Id: containers.vger.kernel.org On 2013/7/29 17:40, Gu Zheng wrote: > Hi Rui, > Refer to inline:). > Hi Gu, Thanks for your attention. > On 07/29/2013 10:31 AM, Rui Xiang wrote: > >> Add a struct syslog_namespace which contains the necessary >> members for hanlding syslog and realize get_syslog_ns and >> put_syslog_ns API. >> >> Signed-off-by: Rui Xiang >> --- >> include/linux/syslog.h | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ >> kernel/printk.c | 7 ------ >> 2 files changed, 68 insertions(+), 7 deletions(-) >> ... >> + >> +static inline void free_syslog_ns(struct kref *kref) >> +{ >> + struct syslog_namespace *ns; >> + ns = container_of(kref, struct syslog_namespace, kref); >> + >> + kfree(ns->log_buf); >> + kfree(ns); >> +} > > This interface seems a bit ugly, why not use the format like put_syslog_ns()? > > static inline void free_syslog_ns(struct syslog_namespace *ns) > Free_syslog_ns is used in put_syslog_ns. And the kref_put function uses kref as a parameter for its relase funtion. You can see that from static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref)). Thanks. >> + >> +static inline void put_syslog_ns(struct syslog_namespace *ns) >> +{ >> + if (ns) >> + kref_put(&ns->kref, free_syslog_ns); >> +} >> + >> From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753463Ab3G2Lrn (ORCPT ); Mon, 29 Jul 2013 07:47:43 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:40422 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752126Ab3G2Lrl (ORCPT ); Mon, 29 Jul 2013 07:47:41 -0400 Message-ID: <51F65636.6080505@huawei.com> Date: Mon, 29 Jul 2013 19:47:02 +0800 From: Rui Xiang User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: Gu Zheng CC: , , , , , , Subject: Re: [PATCH 1/9] syslog_ns: add syslog_namespace and put/get_syslog_ns References: <1375065080-26740-1-git-send-email-rui.xiang@huawei.com> <1375065080-26740-2-git-send-email-rui.xiang@huawei.com> <51F6388B.8000308@cn.fujitsu.com> In-Reply-To: <51F6388B.8000308@cn.fujitsu.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.135.72.188] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2013/7/29 17:40, Gu Zheng wrote: > Hi Rui, > Refer to inline:). > Hi Gu, Thanks for your attention. > On 07/29/2013 10:31 AM, Rui Xiang wrote: > >> Add a struct syslog_namespace which contains the necessary >> members for hanlding syslog and realize get_syslog_ns and >> put_syslog_ns API. >> >> Signed-off-by: Rui Xiang >> --- >> include/linux/syslog.h | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++ >> kernel/printk.c | 7 ------ >> 2 files changed, 68 insertions(+), 7 deletions(-) >> ... >> + >> +static inline void free_syslog_ns(struct kref *kref) >> +{ >> + struct syslog_namespace *ns; >> + ns = container_of(kref, struct syslog_namespace, kref); >> + >> + kfree(ns->log_buf); >> + kfree(ns); >> +} > > This interface seems a bit ugly, why not use the format like put_syslog_ns()? > > static inline void free_syslog_ns(struct syslog_namespace *ns) > Free_syslog_ns is used in put_syslog_ns. And the kref_put function uses kref as a parameter for its relase funtion. You can see that from static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref)). Thanks. >> + >> +static inline void put_syslog_ns(struct syslog_namespace *ns) >> +{ >> + if (ns) >> + kref_put(&ns->kref, free_syslog_ns); >> +} >> + >>