All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 21/24] lustre: move remainder of linux-tracefile.c to tracefile.c
Date: Thu, 21 Jun 2018 02:37:35 +0100 (BST)	[thread overview]
Message-ID: <alpine.LFD.2.21.1806210236200.3886@casper.infradead.org> (raw)
In-Reply-To: <152904669084.10587.6920959206498193596.stgit@noble>


> It's good to keep related code together.
> 
> Signed-off-by: NeilBrown <neilb@suse.com>

Nak. For some reason this corrupts my dmesg output. Its really strange and
I haven't figured it out yet.

> ---
>  drivers/staging/lustre/lnet/libcfs/Makefile        |    2 
>  .../staging/lustre/lnet/libcfs/linux-tracefile.c   |  194 --------------------
>  drivers/staging/lustre/lnet/libcfs/tracefile.c     |  155 ++++++++++++++++
>  3 files changed, 156 insertions(+), 195 deletions(-)
>  delete mode 100644 drivers/staging/lustre/lnet/libcfs/linux-tracefile.c
> 
> diff --git a/drivers/staging/lustre/lnet/libcfs/Makefile b/drivers/staging/lustre/lnet/libcfs/Makefile
> index 1b6937c3deee..22c0e0c2e9cf 100644
> --- a/drivers/staging/lustre/lnet/libcfs/Makefile
> +++ b/drivers/staging/lustre/lnet/libcfs/Makefile
> @@ -3,7 +3,7 @@ ccflags-y += -I$(srctree)/drivers/staging/lustre/include
>  ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include
>  ccflags-y += -DKBUILD_MODNAME='"lnet"'
>  
> -libcfs-obj-y += linux-tracefile.o linux-debug.o
> +libcfs-obj-y += linux-debug.o
>  libcfs-obj-y += linux-crypto.o
>  libcfs-obj-y += linux-crypto-adler.o
>  
> diff --git a/drivers/staging/lustre/lnet/libcfs/linux-tracefile.c b/drivers/staging/lustre/lnet/libcfs/linux-tracefile.c
> deleted file mode 100644
> index 3af77228cd7a..000000000000
> --- a/drivers/staging/lustre/lnet/libcfs/linux-tracefile.c
> +++ /dev/null
> @@ -1,194 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -/*
> - * GPL HEADER START
> - *
> - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License version 2 only,
> - * as published by the Free Software Foundation.
> - *
> - * This program is distributed in the hope that it will be useful, but
> - * WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> - * General Public License version 2 for more details (a copy is included
> - * in the LICENSE file that accompanied this code).
> - *
> - * You should have received a copy of the GNU General Public License
> - * version 2 along with this program; If not, see
> - * http://www.gnu.org/licenses/gpl-2.0.html
> - *
> - * GPL HEADER END
> - */
> -/*
> - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
> - * Use is subject to license terms.
> - *
> - * Copyright (c) 2012, Intel Corporation.
> - */
> -/*
> - * This file is part of Lustre, http://www.lustre.org/
> - * Lustre is a trademark of Sun Microsystems, Inc.
> - */
> -
> -#define DEBUG_SUBSYSTEM S_LNET
> -#define LUSTRE_TRACEFILE_PRIVATE
> -
> -#include <linux/slab.h>
> -#include <linux/mm.h>
> -#include "tracefile.h"
> -
> -/* percents to share the total debug memory for each type */
> -static unsigned int pages_factor[CFS_TCD_TYPE_MAX] = {
> -	80,  /* 80% pages for CFS_TCD_TYPE_PROC */
> -	10,  /* 10% pages for CFS_TCD_TYPE_SOFTIRQ */
> -	10   /* 10% pages for CFS_TCD_TYPE_IRQ */
> -};
> -
> -char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX];
> -
> -int cfs_tracefile_init_arch(void)
> -{
> -	int i;
> -	int j;
> -	struct cfs_trace_cpu_data *tcd;
> -
> -	/* initialize trace_data */
> -	memset(cfs_trace_data, 0, sizeof(cfs_trace_data));
> -	for (i = 0; i < CFS_TCD_TYPE_MAX; i++) {
> -		cfs_trace_data[i] =
> -			kmalloc_array(num_possible_cpus(),
> -				      sizeof(union cfs_trace_data_union),
> -				      GFP_KERNEL);
> -		if (!cfs_trace_data[i])
> -			goto out;
> -	}
> -
> -	/* arch related info initialized */
> -	cfs_tcd_for_each(tcd, i, j) {
> -		spin_lock_init(&tcd->tcd_lock);
> -		tcd->tcd_pages_factor = pages_factor[i];
> -		tcd->tcd_type = i;
> -		tcd->tcd_cpu = j;
> -	}
> -
> -	for (i = 0; i < num_possible_cpus(); i++)
> -		for (j = 0; j < 3; j++) {
> -			cfs_trace_console_buffers[i][j] =
> -				kmalloc(CFS_TRACE_CONSOLE_BUFFER_SIZE,
> -					GFP_KERNEL);
> -
> -			if (!cfs_trace_console_buffers[i][j])
> -				goto out;
> -		}
> -
> -	return 0;
> -
> -out:
> -	cfs_tracefile_fini_arch();
> -	pr_err("lnet: Not enough memory\n");
> -	return -ENOMEM;
> -}
> -
> -void cfs_tracefile_fini_arch(void)
> -{
> -	int i;
> -	int j;
> -
> -	for (i = 0; i < num_possible_cpus(); i++)
> -		for (j = 0; j < 3; j++) {
> -			kfree(cfs_trace_console_buffers[i][j]);
> -			cfs_trace_console_buffers[i][j] = NULL;
> -		}
> -
> -	for (i = 0; cfs_trace_data[i]; i++) {
> -		kfree(cfs_trace_data[i]);
> -		cfs_trace_data[i] = NULL;
> -	}
> -}
> -
> -enum cfs_trace_buf_type cfs_trace_buf_idx_get(void)
> -{
> -	if (in_irq())
> -		return CFS_TCD_TYPE_IRQ;
> -	if (in_softirq())
> -		return CFS_TCD_TYPE_SOFTIRQ;
> -	return CFS_TCD_TYPE_PROC;
> -}
> -
> -void
> -cfs_set_ptldebug_header(struct ptldebug_header *header,
> -			struct libcfs_debug_msg_data *msgdata,
> -			unsigned long stack)
> -{
> -	struct timespec64 ts;
> -
> -	ktime_get_real_ts64(&ts);
> -
> -	header->ph_subsys = msgdata->msg_subsys;
> -	header->ph_mask = msgdata->msg_mask;
> -	header->ph_cpu_id = smp_processor_id();
> -	header->ph_type = cfs_trace_buf_idx_get();
> -	/* y2038 safe since all user space treats this as unsigned, but
> -	 * will overflow in 2106
> -	 */
> -	header->ph_sec = (u32)ts.tv_sec;
> -	header->ph_usec = ts.tv_nsec / NSEC_PER_USEC;
> -	header->ph_stack = stack;
> -	header->ph_pid = current->pid;
> -	header->ph_line_num = msgdata->msg_line;
> -	header->ph_extern_pid = 0;
> -}
> -
> -static char *
> -dbghdr_to_err_string(struct ptldebug_header *hdr)
> -{
> -	switch (hdr->ph_subsys) {
> -	case S_LND:
> -	case S_LNET:
> -		return "LNetError";
> -	default:
> -		return "LustreError";
> -	}
> -}
> -
> -static char *
> -dbghdr_to_info_string(struct ptldebug_header *hdr)
> -{
> -	switch (hdr->ph_subsys) {
> -	case S_LND:
> -	case S_LNET:
> -		return "LNet";
> -	default:
> -		return "Lustre";
> -	}
> -}
> -
> -void cfs_print_to_console(struct ptldebug_header *hdr, int mask,
> -			  const char *buf, int len, const char *file,
> -			  const char *fn)
> -{
> -	char *prefix = "Lustre", *ptype = NULL;
> -
> -	if (mask & D_EMERG) {
> -		prefix = dbghdr_to_err_string(hdr);
> -		ptype = KERN_EMERG;
> -	} else if (mask & D_ERROR) {
> -		prefix = dbghdr_to_err_string(hdr);
> -		ptype = KERN_ERR;
> -	} else if (mask & D_WARNING) {
> -		prefix = dbghdr_to_info_string(hdr);
> -		ptype = KERN_WARNING;
> -	} else if (mask & (D_CONSOLE | libcfs_printk)) {
> -		prefix = dbghdr_to_info_string(hdr);
> -		ptype = KERN_INFO;
> -	}
> -
> -	if (mask & D_CONSOLE) {
> -		pr_info("%s%s: %.*s", ptype, prefix, len, buf);
> -	} else {
> -		pr_info("%s%s: %d:%d:(%s:%d:%s()) %.*s", ptype, prefix,
> -			hdr->ph_pid, hdr->ph_extern_pid, file,
> -			hdr->ph_line_num, fn, len, buf);
> -	}
> -}
> diff --git a/drivers/staging/lustre/lnet/libcfs/tracefile.c b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> index 6d567a9ad8ea..617edc291035 100644
> --- a/drivers/staging/lustre/lnet/libcfs/tracefile.c
> +++ b/drivers/staging/lustre/lnet/libcfs/tracefile.c
> @@ -168,6 +168,161 @@ static inline void cfs_trace_put_tcd(struct cfs_trace_cpu_data *tcd)
>  	put_cpu();
>  }
>  
> +/* percents to share the total debug memory for each type */
> +static unsigned int pages_factor[CFS_TCD_TYPE_MAX] = {
> +	80,  /* 80% pages for CFS_TCD_TYPE_PROC */
> +	10,  /* 10% pages for CFS_TCD_TYPE_SOFTIRQ */
> +	10   /* 10% pages for CFS_TCD_TYPE_IRQ */
> +};
> +
> +char *cfs_trace_console_buffers[NR_CPUS][CFS_TCD_TYPE_MAX];
> +
> +int cfs_tracefile_init_arch(void)
> +{
> +	int i;
> +	int j;
> +	struct cfs_trace_cpu_data *tcd;
> +
> +	/* initialize trace_data */
> +	memset(cfs_trace_data, 0, sizeof(cfs_trace_data));
> +	for (i = 0; i < CFS_TCD_TYPE_MAX; i++) {
> +		cfs_trace_data[i] =
> +			kmalloc_array(num_possible_cpus(),
> +				      sizeof(union cfs_trace_data_union),
> +				      GFP_KERNEL);
> +		if (!cfs_trace_data[i])
> +			goto out;
> +	}
> +
> +	/* arch related info initialized */
> +	cfs_tcd_for_each(tcd, i, j) {
> +		spin_lock_init(&tcd->tcd_lock);
> +		tcd->tcd_pages_factor = pages_factor[i];
> +		tcd->tcd_type = i;
> +		tcd->tcd_cpu = j;
> +	}
> +
> +	for (i = 0; i < num_possible_cpus(); i++)
> +		for (j = 0; j < 3; j++) {
> +			cfs_trace_console_buffers[i][j] =
> +				kmalloc(CFS_TRACE_CONSOLE_BUFFER_SIZE,
> +					GFP_KERNEL);
> +
> +			if (!cfs_trace_console_buffers[i][j])
> +				goto out;
> +		}
> +
> +	return 0;
> +
> +out:
> +	cfs_tracefile_fini_arch();
> +	pr_err("lnet: Not enough memory\n");
> +	return -ENOMEM;
> +}
> +
> +void cfs_tracefile_fini_arch(void)
> +{
> +	int i;
> +	int j;
> +
> +	for (i = 0; i < num_possible_cpus(); i++)
> +		for (j = 0; j < 3; j++) {
> +			kfree(cfs_trace_console_buffers[i][j]);
> +			cfs_trace_console_buffers[i][j] = NULL;
> +		}
> +
> +	for (i = 0; cfs_trace_data[i]; i++) {
> +		kfree(cfs_trace_data[i]);
> +		cfs_trace_data[i] = NULL;
> +	}
> +}
> +
> +enum cfs_trace_buf_type cfs_trace_buf_idx_get(void)
> +{
> +	if (in_irq())
> +		return CFS_TCD_TYPE_IRQ;
> +	if (in_softirq())
> +		return CFS_TCD_TYPE_SOFTIRQ;
> +	return CFS_TCD_TYPE_PROC;
> +}
> +
> +void
> +cfs_set_ptldebug_header(struct ptldebug_header *header,
> +			struct libcfs_debug_msg_data *msgdata,
> +			unsigned long stack)
> +{
> +	struct timespec64 ts;
> +
> +	ktime_get_real_ts64(&ts);
> +
> +	header->ph_subsys = msgdata->msg_subsys;
> +	header->ph_mask = msgdata->msg_mask;
> +	header->ph_cpu_id = smp_processor_id();
> +	header->ph_type = cfs_trace_buf_idx_get();
> +	/* y2038 safe since all user space treats this as unsigned, but
> +	 * will overflow in 2106
> +	 */
> +	header->ph_sec = (u32)ts.tv_sec;
> +	header->ph_usec = ts.tv_nsec / NSEC_PER_USEC;
> +	header->ph_stack = stack;
> +	header->ph_pid = current->pid;
> +	header->ph_line_num = msgdata->msg_line;
> +	header->ph_extern_pid = 0;
> +}
> +
> +static char *
> +dbghdr_to_err_string(struct ptldebug_header *hdr)
> +{
> +	switch (hdr->ph_subsys) {
> +	case S_LND:
> +	case S_LNET:
> +		return "LNetError";
> +	default:
> +		return "LustreError";
> +	}
> +}
> +
> +static char *
> +dbghdr_to_info_string(struct ptldebug_header *hdr)
> +{
> +	switch (hdr->ph_subsys) {
> +	case S_LND:
> +	case S_LNET:
> +		return "LNet";
> +	default:
> +		return "Lustre";
> +	}
> +}
> +
> +void cfs_print_to_console(struct ptldebug_header *hdr, int mask,
> +			  const char *buf, int len, const char *file,
> +			  const char *fn)
> +{
> +	char *prefix = "Lustre", *ptype = NULL;
> +
> +	if (mask & D_EMERG) {
> +		prefix = dbghdr_to_err_string(hdr);
> +		ptype = KERN_EMERG;
> +	} else if (mask & D_ERROR) {
> +		prefix = dbghdr_to_err_string(hdr);
> +		ptype = KERN_ERR;
> +	} else if (mask & D_WARNING) {
> +		prefix = dbghdr_to_info_string(hdr);
> +		ptype = KERN_WARNING;
> +	} else if (mask & (D_CONSOLE | libcfs_printk)) {
> +		prefix = dbghdr_to_info_string(hdr);
> +		ptype = KERN_INFO;
> +	}
> +
> +	if (mask & D_CONSOLE) {
> +		pr_info("%s%s: %.*s", ptype, prefix, len, buf);
> +	} else {
> +		pr_info("%s%s: %d:%d:(%s:%d:%s()) %.*s", ptype, prefix,
> +			hdr->ph_pid, hdr->ph_extern_pid, file,
> +			hdr->ph_line_num, fn, len, buf);
> +	}
> +}
> +
>  static inline struct cfs_trace_page *
>  cfs_tage_from_list(struct list_head *list)
>  {
> 
> 
> 

  reply	other threads:[~2018-06-21  1:37 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15  7:11 [lustre-devel] [PATCH 00/24] lustre - more cleanups including module reduction NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 18/24] lustre/lnet: move tracefile locking from linux-tracefile.c to tracefile.c NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 17/24] lustre: remove lustre_compat.h NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 21/24] lustre: move remainder of linux-tracefile.c to tracefile.c NeilBrown
2018-06-21  1:37   ` James Simmons [this message]
2018-06-22  3:19     ` NeilBrown
2018-06-24 20:29       ` James Simmons
2018-06-24 23:25         ` NeilBrown
2018-06-25 21:52           ` James Simmons
2018-06-15  7:11 ` [lustre-devel] [PATCH 03/24] kbuild: support building of per-directory mod.a NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 16/24] lustre: remove redefinition of module_init() NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 06/24] lustre: build ldlm in the ldlm directory NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 05/24] kbuild: Add documentation for modobj-m NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 11/24] lustre: discard current_n*groups macros NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 04/24] kbuild: disable KBUILD_MODNAME when building for mod.a NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 24/24] lustre: discard TCD_MAX_TYPES NeilBrown
2018-06-21  1:38   ` James Simmons
2018-06-21  4:28     ` NeilBrown
2018-06-24 20:37       ` James Simmons
2018-06-24 23:26         ` NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 13/24] lustre: discard NO_QUOTA and QUOTA_OK NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 01/24] kbuild: detect directories in components of a module NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 22/24] lustre: fold cfs_tracefile_*_arch into their only callers NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 08/24] lustre: use truncate_inode_page in place of truncate_complete_page NeilBrown
2018-06-16  0:17   ` James Simmons
2018-06-16  0:52     ` NeilBrown
2018-06-16  0:59       ` Oleg Drokin
2018-06-18  2:03         ` NeilBrown
2018-06-25  0:02           ` [lustre-devel] [PATCH 1/3] lustre: use generic_error_remove_page() NeilBrown
2018-06-25  0:02             ` [lustre-devel] [PATCH 2/3] lustre: use delete_from_page_cache() for directory pages NeilBrown
2018-06-25  0:03               ` [lustre-devel] [PATCH 3/3] lustre: discard truncate_complete_page() NeilBrown
2018-06-26  0:19                 ` James Simmons
2018-06-25  0:38               ` [lustre-devel] [PATCH 2/3] lustre: use delete_from_page_cache() for directory pages Oleg Drokin
2018-06-26  0:18               ` James Simmons
2018-06-25  0:38             ` [lustre-devel] [PATCH 1/3] lustre: use generic_error_remove_page() Oleg Drokin
2018-06-25  1:57               ` NeilBrown
2018-06-26  0:26                 ` James Simmons
2018-06-26  0:14             ` James Simmons
2018-06-15  7:11 ` [lustre-devel] [PATCH 15/24] lustre: centralize TIMES_SET_FLAGS NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 07/24] lustre: merge libcfs module into lnet NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 09/24] lustre: don't use spare bits in iattr.ia_valid NeilBrown
2018-06-21  1:35   ` James Simmons
2018-06-21  4:19     ` NeilBrown
2018-06-22  2:23       ` NeilBrown
2018-06-24 20:33         ` James Simmons
2018-06-24 23:50           ` NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 20/24] lustre: move tcd locking across to tracefile.c NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 10/24] lustre: remove lustre_patchless_compat.h NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 19/24] lustre: open code cfs_trace_max_debug_mb() into cfs_trace_set_debug_mb() NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 02/24] kbuild: treat a directory listed in a composite object as foo/mod.a NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 14/24] lustre: discard ext2* bit operations NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 12/24] lustre: discard LTIME_S macro NeilBrown
2018-06-15  7:11 ` [lustre-devel] [PATCH 23/24] lustre: renamed CFS_TCD_TYPE_MAX to CFS_TCD_TYPE_CNT NeilBrown
2018-06-21  1:48 ` [lustre-devel] [PATCH 00/24] lustre - more cleanups including module reduction James Simmons
2018-06-21  2:29   ` Patrick Farrell
2018-06-21  2:57     ` James Simmons
2018-06-21  7:22       ` Andreas Dilger
2018-06-21 12:28         ` Patrick Farrell
2018-06-24 20:35           ` James Simmons
2018-06-24 23:40           ` NeilBrown
2018-06-26  1:13             ` James Simmons
2018-06-26 13:51               ` Patrick Farrell
2018-06-27  3:08                 ` NeilBrown
2018-06-27  4:00                   ` Cory Spitz
2018-06-28  1:26                     ` NeilBrown
2018-06-27 11:01                   ` Andreas Dilger
2018-06-27 12:06                     ` Patrick Farrell
2018-06-28  1:59                       ` NeilBrown
2018-06-28  2:35                         ` Patrick Farrell
2018-06-28 23:12                           ` Andreas Dilger
2018-07-05 23:47                             ` James Simmons
2018-07-06  0:01                               ` Doug Oucharek
2018-06-28 15:03                         ` Cory Spitz
2018-06-28 17:03                           ` Doug Oucharek
2018-07-04 17:54                             ` Alexey Lyashkov
2018-06-28  1:39                     ` NeilBrown
2018-06-21  3:00     ` NeilBrown
2018-06-21  3:42       ` Patrick Farrell
2018-06-24 20:39       ` James Simmons
2018-06-21  2:54   ` NeilBrown
2018-06-24 20:46     ` James Simmons
2018-06-24 23:58       ` NeilBrown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.21.1806210236200.3886@casper.infradead.org \
    --to=jsimmons@infradead.org \
    --cc=lustre-devel@lists.lustre.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.