Skip to contentSkip to conversation

fs/pstore: Optimization function ramoops_init_przs

PATCH In review Wang Long 2 participants 3 messages Mar 18, 2015 – May 4, 2015 Pstore filesystem

lore
Share & tools
lore

Wang Long

author
#0 lore raw

PATCH v2 1/1 fs/pstore: Optimization function ramoops_init_przs

The value of cxt->record_size does not change in the loop, so this patch optimize the assign statement by dropping sz entirely and using cxt->record_size in its place.

---
 fs/pstore/ram.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
fs/pstore/ram.c +3 -5
index 44a549b..f29373d 100644
@@ -394,18 +394,16 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt,
 	}
 
 	for (i = 0; i < cxt->max_dump_cnt; i++) {
-		size_t sz = cxt->record_size;
-
-		cxt->przs[i] = persistent_ram_new(*paddr, sz, 0,
+		cxt->przs[i] = persistent_ram_new(*paddr, cxt->record_size, 0,
 						  &cxt->ecc_info,
 						  cxt->memtype);
 		if (IS_ERR(cxt->przs[i])) {
 			err = PTR_ERR(cxt->przs[i]);
 			dev_err(dev, "failed to request mem region (0x%zx@0x%llx): %d\n",
-				sz, (unsigned long long)*paddr, err);
+				cxt->record_size, (unsigned long long)*paddr, err);
 			goto fail_prz;
 		}
-		*paddr += sz;
+		*paddr += cxt->record_size;
 	}
 
 	return 0;
Signature · 1 line
1.8.3.4
Acked-by on v2 1/1
#1 lore raw
Quoted 5 lines · Wang Long

The value of cxt->record_size does not change in the loop, so this patch optimize the assign statement by dropping sz entirely and using cxt->record_size in its place.

Thanks!

-Kees

Quoted 38 lines
---
 fs/pstore/ram.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
fs/pstore/ram.c +3 -6
index 44a549b..f29373d 100644
@@ -394,18 +394,16 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt,
        }
 
        for (i = 0; i < cxt->max_dump_cnt; i++) {
-               size_t sz = cxt->record_size;
-
-               cxt->przs[i] = persistent_ram_new(*paddr, sz, 0,
+               cxt->przs[i] = persistent_ram_new(*paddr, cxt->record_size, 0,
                                                  &cxt->ecc_info,
                                                  cxt->memtype);
                if (IS_ERR(cxt->przs[i])) {
                        err = PTR_ERR(cxt->przs[i]);
                        dev_err(dev, "failed to request mem region (0x%zx@0x%llx): %d\n",
-                               sz, (unsigned long long)*paddr, err);
+                               cxt->record_size, (unsigned long long)*paddr, err);
                        goto fail_prz;
                }
-               *paddr += sz;
+               *paddr += cxt->record_size;
        }
 
        return 0;
--

1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 2 lines
Kees Cook
Chrome OS Security
#2 lore raw
Quoted 46 lines · Kees Cook
Quoted 5 lines · Wang Long

The value of cxt->record_size does not change in the loop, so this patch optimize the assign statement by dropping sz entirely and using cxt->record_size in its place.

Thanks!

-Kees

Quoted 33 lines
---
 fs/pstore/ram.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
fs/pstore/ram.c +3 -6
index 44a549b..f29373d 100644
@@ -394,18 +394,16 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt,
        }
 
        for (i = 0; i < cxt->max_dump_cnt; i++) {
-               size_t sz = cxt->record_size;
-
-               cxt->przs[i] = persistent_ram_new(*paddr, sz, 0,
+               cxt->przs[i] = persistent_ram_new(*paddr, cxt->record_size, 0,
                                                  &cxt->ecc_info,
                                                  cxt->memtype);
                if (IS_ERR(cxt->przs[i])) {
                        err = PTR_ERR(cxt->przs[i]);
                        dev_err(dev, "failed to request mem region (0x%zx@0x%llx): %d\n",
-                               sz, (unsigned long long)*paddr, err);
+                               cxt->record_size, (unsigned long long)*paddr, err);
                        goto fail_prz;
                }
-               *paddr += sz;
+               *paddr += cxt->record_size;
        }
 
        return 0;
--

1.8.3.4

Quoted 8 lines
Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Hi Tony Luck,

Could you please help to commit this patch?

Thank you.

Best Regards
Wang Long