Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1646705 > unrolled thread

[PATCH 1/2]pstore: Move timestamp collection code to common pstore place

Started byAnkit Kumar <ankit@linux.vnet.ibm.com>
First post2017-05-22 12:30 +0200
Last post2017-05-23 10:20 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2]pstore: Move timestamp collection code to common pstore place Ankit Kumar <ankit@linux.vnet.ibm.com> - 2017-05-22 12:30 +0200
    Re: [PATCH 1/2]pstore: Move timestamp collection code to common  pstore place Kees Cook <keescook@chromium.org> - 2017-05-23 01:40 +0200
      Re: [PATCH 1/2]pstore: Move timestamp collection code to common  pstore place Ankit Kumar <ankit@linux.vnet.ibm.com> - 2017-05-23 10:20 +0200

#1646705 — [PATCH 1/2]pstore: Move timestamp collection code to common pstore place

FromAnkit Kumar <ankit@linux.vnet.ibm.com>
Date2017-05-22 12:30 +0200
Subject[PATCH 1/2]pstore: Move timestamp collection code to common pstore place
Message-ID<tJSL8-4td-15@gated-at.bofh.it>
Current pstore code(ram.c) gets dump timestamp and make it part of header.
Different diffent architecture uses different header format and hence it
won't be good idea to make ramoops_write_kmsg_hdr/ramoops_read_kmsg_hdr
part of generic pstore code.

ramoops_write_kmsg_hdr calls __getnstimeofday to get timestamp and also
takes care of condition if timekeeping has not resumed.

This patch moves code for retrieving timestamp to common place and hence
can be used by other functions as well.

Signed-off-by: Ankit Kumar <ankit@linux.vnet.ibm.com>
---
 fs/pstore/internal.h |  1 +
 fs/pstore/platform.c | 13 +++++++++++++
 fs/pstore/ram.c      |  9 ++++-----
 3 files changed, 18 insertions(+), 5 deletions(-)

diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h
index c416e65..339dcdc 100644
--- a/fs/pstore/internal.h
+++ b/fs/pstore/internal.h
@@ -22,6 +22,7 @@ static inline void pstore_unregister_pmsg(void) {}
 #endif
 
 extern struct pstore_info *psinfo;
+void pstore_get_timestamp(struct timespec *timestamp);
 
 extern void	pstore_set_kmsg_bytes(int);
 extern void	pstore_get_records(int);
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index d468eec..5cb25b0 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -474,6 +474,19 @@ static size_t copy_kmsg_to_buffer(int hsize, size_t len)
 	return total_len;
 }
 
+void pstore_get_timestamp(struct timespec *timestamp)
+{
+	if (!timestamp)
+		return;
+
+	/* Report zeroed timestamp if called before timekeeping has resumed. */
+	if (__getnstimeofday(timestamp)) {
+		timestamp->tv_sec = 0;
+		timestamp->tv_nsec = 0;
+	}
+}
+EXPORT_SYMBOL_GPL(pstore_get_timestamp);
+
 /*
  * callback from kmsg_dump. (s2,l2) has the most recently
  * written bytes, older bytes are in (s1,l1). Save as much
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 5cb022c..e39297d 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -37,6 +37,8 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 
+#include "internal.h"
+
 #define RAMOOPS_KERNMSG_HDR "===="
 #define MIN_MEM_SIZE 4096UL
 
@@ -362,11 +364,8 @@ static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz,
 	struct timespec timestamp;
 	size_t len;
 
-	/* Report zeroed timestamp if called before timekeeping has resumed. */
-	if (__getnstimeofday(&timestamp)) {
-		timestamp.tv_sec = 0;
-		timestamp.tv_nsec = 0;
-	}
+	pstore_get_timestamp(&timestamp);
+
 	hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lu.%lu-%c\n",
 		(long)timestamp.tv_sec, (long)(timestamp.tv_nsec / 1000),
 		compressed ? 'C' : 'D');
-- 
2.7.4

[toc] | [next] | [standalone]


#1647492 — Re: [PATCH 1/2]pstore: Move timestamp collection code to common pstore place

FromKees Cook <keescook@chromium.org>
Date2017-05-23 01:40 +0200
SubjectRe: [PATCH 1/2]pstore: Move timestamp collection code to common pstore place
Message-ID<tK55E-3FX-13@gated-at.bofh.it>
In reply to#1646705
On Mon, May 22, 2017 at 3:20 AM, Ankit Kumar <ankit@linux.vnet.ibm.com> wrote:
> Current pstore code(ram.c) gets dump timestamp and make it part of header.
> Different diffent architecture uses different header format and hence it
> won't be good idea to make ramoops_write_kmsg_hdr/ramoops_read_kmsg_hdr
> part of generic pstore code.
>
> ramoops_write_kmsg_hdr calls __getnstimeofday to get timestamp and also
> takes care of condition if timekeeping has not resumed.
>
> This patch moves code for retrieving timestamp to common place and hence
> can be used by other functions as well.

Ah! Heh, funny, I had just done a version of this while working on EFI
pstore fixes. Here's what I did instead:

https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?h=pstore/fixes&id=ea209b760f104daf0cf62953090b66c5628b0842

This makes it so the time field is prepopulated for all backend
writes, which should simplify things (no need to have the backends
call out).

-Kees

>
> Signed-off-by: Ankit Kumar <ankit@linux.vnet.ibm.com>
> ---
>  fs/pstore/internal.h |  1 +
>  fs/pstore/platform.c | 13 +++++++++++++
>  fs/pstore/ram.c      |  9 ++++-----
>  3 files changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h
> index c416e65..339dcdc 100644
> --- a/fs/pstore/internal.h
> +++ b/fs/pstore/internal.h
> @@ -22,6 +22,7 @@ static inline void pstore_unregister_pmsg(void) {}
>  #endif
>
>  extern struct pstore_info *psinfo;
> +void pstore_get_timestamp(struct timespec *timestamp);
>
>  extern void    pstore_set_kmsg_bytes(int);
>  extern void    pstore_get_records(int);
> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
> index d468eec..5cb25b0 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -474,6 +474,19 @@ static size_t copy_kmsg_to_buffer(int hsize, size_t len)
>         return total_len;
>  }
>
> +void pstore_get_timestamp(struct timespec *timestamp)
> +{
> +       if (!timestamp)
> +               return;
> +
> +       /* Report zeroed timestamp if called before timekeeping has resumed. */
> +       if (__getnstimeofday(timestamp)) {
> +               timestamp->tv_sec = 0;
> +               timestamp->tv_nsec = 0;
> +       }
> +}
> +EXPORT_SYMBOL_GPL(pstore_get_timestamp);
> +
>  /*
>   * callback from kmsg_dump. (s2,l2) has the most recently
>   * written bytes, older bytes are in (s1,l1). Save as much
> diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
> index 5cb022c..e39297d 100644
> --- a/fs/pstore/ram.c
> +++ b/fs/pstore/ram.c
> @@ -37,6 +37,8 @@
>  #include <linux/of.h>
>  #include <linux/of_address.h>
>
> +#include "internal.h"
> +
>  #define RAMOOPS_KERNMSG_HDR "===="
>  #define MIN_MEM_SIZE 4096UL
>
> @@ -362,11 +364,8 @@ static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz,
>         struct timespec timestamp;
>         size_t len;
>
> -       /* Report zeroed timestamp if called before timekeeping has resumed. */
> -       if (__getnstimeofday(&timestamp)) {
> -               timestamp.tv_sec = 0;
> -               timestamp.tv_nsec = 0;
> -       }
> +       pstore_get_timestamp(&timestamp);
> +
>         hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lu.%lu-%c\n",
>                 (long)timestamp.tv_sec, (long)(timestamp.tv_nsec / 1000),
>                 compressed ? 'C' : 'D');
> --
> 2.7.4
>



-- 
Kees Cook
Pixel Security

[toc] | [prev] | [next] | [standalone]


#1647777 — Re: [PATCH 1/2]pstore: Move timestamp collection code to common pstore place

FromAnkit Kumar <ankit@linux.vnet.ibm.com>
Date2017-05-23 10:20 +0200
SubjectRe: [PATCH 1/2]pstore: Move timestamp collection code to common pstore place
Message-ID<tKdcS-x7-7@gated-at.bofh.it>
In reply to#1647492
Hi Kees,

Thank you so much for your response.



On Tuesday 23 May 2017 05:07 AM, Kees Cook wrote:
> On Mon, May 22, 2017 at 3:20 AM, Ankit Kumar <ankit@linux.vnet.ibm.com> wrote:
>> Current pstore code(ram.c) gets dump timestamp and make it part of header.
>> Different diffent architecture uses different header format and hence it
>> won't be good idea to make ramoops_write_kmsg_hdr/ramoops_read_kmsg_hdr
>> part of generic pstore code.
>>
>> ramoops_write_kmsg_hdr calls __getnstimeofday to get timestamp and also
>> takes care of condition if timekeeping has not resumed.
>>
>> This patch moves code for retrieving timestamp to common place and hence
>> can be used by other functions as well.
> Ah! Heh, funny, I had just done a version of this while working on EFI
> pstore fixes. Here's what I did instead:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?h=pstore/fixes&id=ea209b760f104daf0cf62953090b66c5628b0842
>
> This makes it so the time field is prepopulated for all backend
> writes, which should simplify things (no need to have the backends
> call out).


Above mentioned patch moves code to common place and also simplifies things.
I agree, My patch is not required anymore.

Thank you;

~Ankit




> -Kees
>
>> Signed-off-by: Ankit Kumar <ankit@linux.vnet.ibm.com>
>> ---
>>   fs/pstore/internal.h |  1 +
>>   fs/pstore/platform.c | 13 +++++++++++++
>>   fs/pstore/ram.c      |  9 ++++-----
>>   3 files changed, 18 insertions(+), 5 deletions(-)
>>
>> diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h
>> index c416e65..339dcdc 100644
>> --- a/fs/pstore/internal.h
>> +++ b/fs/pstore/internal.h
>> @@ -22,6 +22,7 @@ static inline void pstore_unregister_pmsg(void) {}
>>   #endif
>>
>>   extern struct pstore_info *psinfo;
>> +void pstore_get_timestamp(struct timespec *timestamp);
>>
>>   extern void    pstore_set_kmsg_bytes(int);
>>   extern void    pstore_get_records(int);
>> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
>> index d468eec..5cb25b0 100644
>> --- a/fs/pstore/platform.c
>> +++ b/fs/pstore/platform.c
>> @@ -474,6 +474,19 @@ static size_t copy_kmsg_to_buffer(int hsize, size_t len)
>>          return total_len;
>>   }
>>
>> +void pstore_get_timestamp(struct timespec *timestamp)
>> +{
>> +       if (!timestamp)
>> +               return;
>> +
>> +       /* Report zeroed timestamp if called before timekeeping has resumed. */
>> +       if (__getnstimeofday(timestamp)) {
>> +               timestamp->tv_sec = 0;
>> +               timestamp->tv_nsec = 0;
>> +       }
>> +}
>> +EXPORT_SYMBOL_GPL(pstore_get_timestamp);
>> +
>>   /*
>>    * callback from kmsg_dump. (s2,l2) has the most recently
>>    * written bytes, older bytes are in (s1,l1). Save as much
>> diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
>> index 5cb022c..e39297d 100644
>> --- a/fs/pstore/ram.c
>> +++ b/fs/pstore/ram.c
>> @@ -37,6 +37,8 @@
>>   #include <linux/of.h>
>>   #include <linux/of_address.h>
>>
>> +#include "internal.h"
>> +
>>   #define RAMOOPS_KERNMSG_HDR "===="
>>   #define MIN_MEM_SIZE 4096UL
>>
>> @@ -362,11 +364,8 @@ static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz,
>>          struct timespec timestamp;
>>          size_t len;
>>
>> -       /* Report zeroed timestamp if called before timekeeping has resumed. */
>> -       if (__getnstimeofday(&timestamp)) {
>> -               timestamp.tv_sec = 0;
>> -               timestamp.tv_nsec = 0;
>> -       }
>> +       pstore_get_timestamp(&timestamp);
>> +
>>          hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lu.%lu-%c\n",
>>                  (long)timestamp.tv_sec, (long)(timestamp.tv_nsec / 1000),
>>                  compressed ? 'C' : 'D');
>> --
>> 2.7.4
>>
>
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web