Linux-EROFS Archive mirror
 help / color / mirror / Atom feed
From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: Yifan Zhao <zhaoyifan@sjtu.edu.cn>
Cc: linux-erofs@lists.ozlabs.org
Subject: Re: [PATCH] erofs-utils: lib: introduce atomic operations
Date: Wed, 28 Feb 2024 22:39:46 +0800	[thread overview]
Message-ID: <4cc27f19-bf68-4ee9-adb8-4c8d8827637e@linux.alibaba.com> (raw)
In-Reply-To: <a8b23de9-1f35-48e9-a4af-8041bbd89739@sjtu.edu.cn>



On 2024/2/28 21:22, Yifan Zhao wrote:
> 
> On 2/28/24 16:21, Gao Xiang wrote:
>> Add some helpers (relaxed semantics) in order to prepare for the
>> upcoming multi-threaded support.
>>
>> For example, compressor may be initialized more than once in different
>> worker threads, resulting in noisy warnings.
>>
>> This patch makes sure that each message will be printed only once by
>> adding `__warnonce` atomic booleans to each erofs_compressor_init().
>>
>> Cc: Yifan Zhao<zhaoyifan@sjtu.edu.cn>
>> Signed-off-by: Gao Xiang<hsiangkao@linux.alibaba.com>
>> ---
>>   include/erofs/atomic.h      | 27 +++++++++++++++++++++++++++
>>   lib/compressor_deflate.c    | 11 ++++++++---
>>   lib/compressor_libdeflate.c |  6 +++++-
>>   lib/compressor_liblzma.c    |  5 ++++-
>>   4 files changed, 44 insertions(+), 5 deletions(-)
>>   create mode 100644 include/erofs/atomic.h
>>
>> diff --git a/include/erofs/atomic.h b/include/erofs/atomic.h
>> new file mode 100644
>> index 0000000..c486491
>> --- /dev/null
>> +++ b/include/erofs/atomic.h
>> @@ -0,0 +1,27 @@
>> +/* SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0 */
>> +/*
>> + * Copyright (C) 2024 Alibaba Cloud
>> + */
>> +#ifndef __EROFS_ATOMIC_H
>> +#define __EROFS_ATOMIC_H
>> +
>> +/*
>> + * Just use GCC/clang built-in functions for now
>> + * See:https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
>> + */
>> +typedef unsigned long erofs_atomic_t;
> 
> According to [1] *__atomic_test_and_set *should**only be used for operands of type bool or char.
> 
> [1] https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
> 
> Maybe add
> 
> /typedef bool erofs_atomic_bool_t;
> /
> 
> for this purpose?
> 
> Otherwise LGTM and I will include it in my patchset.

Ok, I'm fine with that. you could revise it directly.

Thanks,
Gao Xiang

      reply	other threads:[~2024-02-28 14:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-28  8:21 [PATCH] erofs-utils: lib: introduce atomic operations Gao Xiang
2024-02-28 13:22 ` Yifan Zhao
2024-02-28 14:39   ` Gao Xiang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4cc27f19-bf68-4ee9-adb8-4c8d8827637e@linux.alibaba.com \
    --to=hsiangkao@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=zhaoyifan@sjtu.edu.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).