linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Waychison <mikew-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
To: Robin Dong <hao.bigrat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Robin Dong <sanbai-3b8fjiQLQpfQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH v3,23/23] netoops: Add OOM event to dump.
Date: Fri, 22 Apr 2011 12:13:47 -0700	[thread overview]
Message-ID: <BANLkTimyBqe=SdQ_hyj1uv3VP6QeqtJS5w@mail.gmail.com> (raw)
In-Reply-To: <1303471321-11863-1-git-send-email-hao.bigrat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Fri, Apr 22, 2011 at 4:22 AM, Robin Dong <hao.bigrat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> From: Robin Dong <sanbai-3b8fjiQLQpfQT0dZR+AlfA@public.gmane.org>
>
> Our team is evaluating the netoops patchs since it is very useful in
> complicated data center environment.
> But we also need to catch the OOM message from remote machine.
> So I add this patch.

Hmm.  I'm wondering if it may make more sense to push this sort of
configuration down into the configfs directories themselves so
different types of events can be configured for each endpoint
independently.  It'd need a bit of support from the netpoll_targets
code to allow that to happen, but I can take a stab at adding it (I'm
going to rebase this work this afternoon).

>
>
> Signed-off-by: Robin Dong <sanbai-3b8fjiQLQpfQT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/net/netoops.c     |   23 ++++++++++++++++++++++-
>  include/linux/kmsg_dump.h |    1 +
>  mm/oom_kill.c             |    3 +++
>  3 files changed, 26 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/netoops.c b/drivers/net/netoops.c
> index 036e4d8..921775d 100644
> --- a/drivers/net/netoops.c
> +++ b/drivers/net/netoops.c
> @@ -113,6 +113,7 @@ static struct netoops_msg msg;
>  static size_t netoops_user_blob_length;
>  static char netoops_user_blob[NETOOPS_BLOB_BYTES];
>  static u32 netoops_boot_id;
> +static u32 netoops_record_oom;
>
>  static void setup_packet_header(int packet_count, struct pt_regs *regs,
>                                int soft_dump)
> @@ -201,10 +202,15 @@ static void netoops(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason,
>        int soft_dump = 0;
>        int i;
>
> +       /* Record oom event only when netoops_record_oom is 1 */
> +       if (reason == KMSG_DUMP_OOM && netoops_record_oom == 0)
> +               return;
> +
>        /* Only handle fatal problems */
>        if (reason != KMSG_DUMP_OOPS
>         && reason != KMSG_DUMP_PANIC
> -        && reason != KMSG_DUMP_SOFT)
> +        && reason != KMSG_DUMP_SOFT
> +        && reason != KMSG_DUMP_OOM)
>                return;
>
>        if (reason == KMSG_DUMP_SOFT)
> @@ -241,6 +247,10 @@ static ssize_t netoops_show(struct kobject *kobj,
>                snprintf(buf, PAGE_SIZE, "%d\n", netoops_boot_id);
>                return strnlen(buf, PAGE_SIZE);
>        }
> +       if (!strcmp(attr->attr.name, "netoops_record_oom")) {
> +               snprintf(buf, PAGE_SIZE, "%d\n", netoops_record_oom);
> +               return strnlen(buf, PAGE_SIZE);
> +       }
>        return -EINVAL;
>  }
>
> @@ -261,6 +271,14 @@ static ssize_t netoops_store(struct kobject *kobj,
>                if (tmp > UINT_MAX)
>                        printk("Warning: truncating boot_id to 32bits.");
>                netoops_boot_id = tmp;
> +       } else if (!strcmp(attr->attr.name, "netoops_record_oom")) {
> +               unsigned long tmp;
> +               if (strict_strtoul(buf, 0, &tmp))
> +                       return -EINVAL;
> +               if (tmp)
> +                       netoops_record_oom = 1;
> +               else
> +                       netoops_record_oom = 0;
>        } else
>                return -EINVAL;
>
> @@ -271,10 +289,13 @@ static struct kobj_attribute netoops_user_blob_attribute =
>        __ATTR(netoops_user_blob, 0644, netoops_show, netoops_store);
>  static struct kobj_attribute netoops_boot_number_attribute =
>        __ATTR(netoops_boot_id, 0666, netoops_show, netoops_store);
> +static struct kobj_attribute netoops_record_oom_attribute =
> +       __ATTR(netoops_record_oom, 0666, netoops_show, netoops_store);
>
>  static struct attribute *attrs[] = {
>        &netoops_user_blob_attribute.attr,
>        &netoops_boot_number_attribute.attr,
> +       &netoops_record_oom_attribute.attr,
>        NULL,
>  };
>
> diff --git a/include/linux/kmsg_dump.h b/include/linux/kmsg_dump.h
> index 0abc2d7..cefbf5f 100644
> --- a/include/linux/kmsg_dump.h
> +++ b/include/linux/kmsg_dump.h
> @@ -21,6 +21,7 @@ enum kmsg_dump_reason {
>        KMSG_DUMP_PANIC,
>        KMSG_DUMP_KEXEC,
>        KMSG_DUMP_SOFT,
> +       KMSG_DUMP_OOM,
>  };
>
>  /**
> diff --git a/mm/oom_kill.c b/mm/oom_kill.c
> index 7dcca55..40f3862 100644
> --- a/mm/oom_kill.c
> +++ b/mm/oom_kill.c
> @@ -31,6 +31,7 @@
>  #include <linux/memcontrol.h>
>  #include <linux/mempolicy.h>
>  #include <linux/security.h>
> +#include <linux/kmsg_dump.h>
>
>  int sysctl_panic_on_oom;
>  int sysctl_oom_kill_allocating_task;
> @@ -742,6 +743,8 @@ out:
>         */
>        if (killed && !test_thread_flag(TIF_MEMDIE))
>                schedule_timeout_uninterruptible(1);
> +
> +       kmsg_dump(KMSG_DUMP_OOM, NULL);
>  }
>
>  /*
> --
> 1.7.1
>
>

      parent reply	other threads:[~2011-04-22 19:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-22 11:22 [PATCH v3,23/23] netoops: Add OOM event to dump Robin Dong
     [not found] ` <1303471321-11863-1-git-send-email-hao.bigrat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2011-04-22 19:13   ` Mike Waychison [this message]

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='BANLkTimyBqe=SdQ_hyj1uv3VP6QeqtJS5w@mail.gmail.com' \
    --to=mikew-hpiqsd4aklfqt0dzr+alfa@public.gmane.org \
    --cc=hao.bigrat-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=sanbai-3b8fjiQLQpfQT0dZR+AlfA@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).