On Thu, Apr 25, 2024 at 02:21:10AM +0000, Hao Xiang wrote: > +/** > + * @brief Performs buffer zero comparison on a DSA batch task asynchronously. > + * > + * @param batch_task A pointer to the batch task. > + * @param buf An array of memory buffers. > + * @param count The number of buffers in the array. > + * @param len The buffer length. > + * > + * @return Zero if successful, otherwise non-zero. > + */ > +int > +buffer_is_zero_dsa_batch_async(struct dsa_batch_task *batch_task, > + const void **buf, size_t count, size_t len)
It says it's "async", but then.. > +{ > + if (count <= 0 || count > batch_task->batch_size) { > + return -1; > + } > + > + assert(batch_task != NULL); > + assert(len != 0); > + assert(buf != NULL); > + > + if (count == 1) { > + /* DSA doesn't take batch operation with only 1 task. */ > + buffer_zero_dsa_async(batch_task, buf[0], len); > + } else { > + buffer_zero_dsa_batch_async(batch_task, buf, count, len); > + } > + > + buffer_zero_dsa_wait(batch_task); ... it waits always. Wrong function name? > + buffer_zero_cpu_fallback(batch_task); Is this introducing yet another path even if it internally still uses buffer_is_zero()? Can we allow buffer_is_zero_dsa_batch_async() (or when it's renamed) fail directly with a hint that it should fallback? Ultimately something like: if (dsa_is_running() && zero_page_detect_dsa(p)) { /* Succeeded */ return; } /* Use cpu detection by default, or as fallback */ zero_page_detect_cpu(); > + > + return 0; > +} > + > #endif > > -- > 2.30.2 > > -- Peter Xu