Skip to content

Commit 161284b

Browse files
committed
Merge branch 'pm-sleep'
Merge fixes for issues related to the handling of compressed hibernation images that were introduced during the 6.9 development cycle. * pm-sleep: PM: hibernate: Fix style issues in save_compressed_image() PM: hibernate: Use atomic64_t for compressed_size variable PM: hibernate: Emit an error when image writing fails
2 parents 4b747cc + 0b6c10c commit 161284b

1 file changed

Lines changed: 13 additions & 9 deletions

File tree

kernel/power/swap.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ struct cmp_data {
635635
};
636636

637637
/* Indicates the image size after compression */
638-
static atomic_t compressed_size = ATOMIC_INIT(0);
638+
static atomic64_t compressed_size = ATOMIC_INIT(0);
639639

640640
/*
641641
* Compression function that runs in its own thread.
@@ -664,7 +664,7 @@ static int compress_threadfn(void *data)
664664
d->ret = crypto_acomp_compress(d->cr);
665665
d->cmp_len = d->cr->dlen;
666666

667-
atomic_set(&compressed_size, atomic_read(&compressed_size) + d->cmp_len);
667+
atomic64_add(d->cmp_len, &compressed_size);
668668
atomic_set_release(&d->stop, 1);
669669
wake_up(&d->done);
670670
}
@@ -689,14 +689,14 @@ static int save_compressed_image(struct swap_map_handle *handle,
689689
ktime_t start;
690690
ktime_t stop;
691691
size_t off;
692-
unsigned thr, run_threads, nr_threads;
692+
unsigned int thr, run_threads, nr_threads;
693693
unsigned char *page = NULL;
694694
struct cmp_data *data = NULL;
695695
struct crc_data *crc = NULL;
696696

697697
hib_init_batch(&hb);
698698

699-
atomic_set(&compressed_size, 0);
699+
atomic64_set(&compressed_size, 0);
700700

701701
/*
702702
* We'll limit the number of threads for compression to limit memory
@@ -877,11 +877,14 @@ static int save_compressed_image(struct swap_map_handle *handle,
877877
stop = ktime_get();
878878
if (!ret)
879879
ret = err2;
880-
if (!ret)
880+
if (!ret) {
881+
swsusp_show_speed(start, stop, nr_to_write, "Wrote");
882+
pr_info("Image size after compression: %lld kbytes\n",
883+
(atomic64_read(&compressed_size) / 1024));
881884
pr_info("Image saving done\n");
882-
swsusp_show_speed(start, stop, nr_to_write, "Wrote");
883-
pr_info("Image size after compression: %d kbytes\n",
884-
(atomic_read(&compressed_size) / 1024));
885+
} else {
886+
pr_err("Image saving failed: %d\n", ret);
887+
}
885888

886889
out_clean:
887890
hib_finish_batch(&hb);
@@ -899,7 +902,8 @@ static int save_compressed_image(struct swap_map_handle *handle,
899902
}
900903
vfree(data);
901904
}
902-
if (page) free_page((unsigned long)page);
905+
if (page)
906+
free_page((unsigned long)page);
903907

904908
return ret;
905909
}

0 commit comments

Comments
 (0)