Message ID | 20181203000542.23224-1-stewart@linux.ibm.com |
---|---|
State | Accepted |
Headers | show |
Series | [v2] libflash/file: greatly increase perf of file_erase() | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | master/apply_patch Successfully applied |
snowpatch_ozlabs/snowpatch_job_snowpatch-skiboot | success | Test snowpatch/job/snowpatch-skiboot on branch master |
On Mon, 2018-12-03 at 11:05 +1100, Stewart Smith wrote: > Do 4096 byte chunks not 8 byte chunks. A ffspart invocation constructing > a 64MB PNOR goes from a couple of seconds to ~0.1seconds with this > patch. > > Signed-off-by: Stewart Smith <stewart@linux.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> > --- > v2: use git properly you git (i.e. don't remove a file) > > libflash/file.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/libflash/file.c b/libflash/file.c > index 49f61778e946..72765b5777f9 100644 > --- a/libflash/file.c > +++ b/libflash/file.c > @@ -117,15 +117,17 @@ static int file_write(struct blocklevel_device *bl, uint64_t dst, const void *sr > */ > static int file_erase(struct blocklevel_device *bl, uint64_t dst, uint64_t len) > { > - unsigned long long int d = ULLONG_MAX; > + char buf[4096]; > int i = 0; > int rc; > > + memset(buf, ~0, sizeof(buf)); > + > while (len - i > 0) { > - rc = file_write(bl, dst + i, &d, len - i > sizeof(d) ? sizeof(d) : len - i); > + rc = file_write(bl, dst + i, buf, len - i > sizeof(buf) ? sizeof(buf) : len - i); > if (rc) > return rc; > - i += len - i > sizeof(d) ? sizeof(d) : len - i; > + i += (len - i > sizeof(buf)) ? sizeof(buf) : len - i; > } > > return 0;
Stewart Smith <stewart@linux.ibm.com> writes: > Do 4096 byte chunks not 8 byte chunks. A ffspart invocation constructing > a 64MB PNOR goes from a couple of seconds to ~0.1seconds with this > patch. > > Signed-off-by: Stewart Smith <stewart@linux.ibm.com> > --- > v2: use git properly you git (i.e. don't remove a file) Merged to master as of 1534ab1dca13403ade020be26989a95156f321e0
diff --git a/libflash/file.c b/libflash/file.c index 49f61778e946..72765b5777f9 100644 --- a/libflash/file.c +++ b/libflash/file.c @@ -117,15 +117,17 @@ static int file_write(struct blocklevel_device *bl, uint64_t dst, const void *sr */ static int file_erase(struct blocklevel_device *bl, uint64_t dst, uint64_t len) { - unsigned long long int d = ULLONG_MAX; + char buf[4096]; int i = 0; int rc; + memset(buf, ~0, sizeof(buf)); + while (len - i > 0) { - rc = file_write(bl, dst + i, &d, len - i > sizeof(d) ? sizeof(d) : len - i); + rc = file_write(bl, dst + i, buf, len - i > sizeof(buf) ? sizeof(buf) : len - i); if (rc) return rc; - i += len - i > sizeof(d) ? sizeof(d) : len - i; + i += (len - i > sizeof(buf)) ? sizeof(buf) : len - i; } return 0;
Do 4096 byte chunks not 8 byte chunks. A ffspart invocation constructing a 64MB PNOR goes from a couple of seconds to ~0.1seconds with this patch. Signed-off-by: Stewart Smith <stewart@linux.ibm.com> --- v2: use git properly you git (i.e. don't remove a file) libflash/file.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)