On Sat, Feb 22, 2025 at 8:23 PM Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> wrote: > > On Sat, Feb 22, 2025 at 08:13:13PM +1300, Barry Song wrote: > > > > Somehow, I find your comment reasonable. Another point I want > > to mention is the semantic difference. For example, in a system > > with only one algorithm, a dst_buf overflow still means a successful > > swap-out. However, other errors actually indicate an I/O failure. > > In such cases, vmscan.c will log the relevant error in pageout() to > > notify the user. > > I'm talking specifically about the error from the Crypto API, > not any other error. So if you werer using some sort of an > offload device to do the compression, that could indeed fail > due to an IO error (perhaps the PCI bus is on fire :) > > But because that's reported through the Crypto API, it should > not be treated any differently than an incompressible page, > except for reporting purposes. I'm referring more to the mm subsystem :-) Let me provide a concrete example. Below is a small program that will swap out 16MB of memory to zRAM: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/mman.h> #include <unistd.h> #define MB (1024 * 1024) #define SIZE (16 * MB) int main() { void *addr = mmap(NULL, SIZE, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); if (addr == MAP_FAILED) { perror("mmap failed"); return 1; } for (size_t i = 0; i < SIZE / sizeof(int); i++) { ((int*)addr)[i] = rand(); } if (madvise(addr, SIZE, MADV_PAGEOUT) != 0) { perror("madvise failed"); return 1; } while (1); return 0; } For errors other than dst_buf overflow, we receive: / # ./a.out & / # free total used free shared buff/cache available Mem: 341228 77036 251872 0 20600 264192 Swap: 2703356 0 2703356 [1]+ Done ./a.out / # cat /proc/vmstat | grep swp pswpin 0 pswpout 0 ... No memory has been swapped out, the swap-out counter is zero, and the swap file is not used at all. If this is an incompressible page(I mean dst_buf overflow error), there is no actual issue, and we get the following: / # / # free total used free shared buff/cache available Mem: 341228 92948 236248 0 20372 248280 Swap: 2703356 16384 2686972 / # cat /proc/vmstat | grep swp pswpin 0 pswpout 4096 ... > > Cheers, > -- > Email: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx> > Home Page: http://gondor.apana.org.au/~herbert/ > PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt > Thanks Barry