From owner-freebsd-hackers@freebsd.org Fri Aug 16 07:23:08 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7F48EC29AA for ; Fri, 16 Aug 2019 07:23:08 +0000 (UTC) (envelope-from agapon@gmail.com) Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 468vtM56Mfz3PMg for ; Fri, 16 Aug 2019 07:23:07 +0000 (UTC) (envelope-from agapon@gmail.com) Received: by mail-pg1-f177.google.com with SMTP id n9so2517450pgc.1 for ; Fri, 16 Aug 2019 00:23:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:openpgp:message-id:date :user-agent:mime-version:content-language:content-transfer-encoding; bh=KdoYBOYsng2RH4z5kF1kl6YbXdQV+8m+qFLvSZtJ7R0=; b=ktPYHSugtg4ayatk61WG7idr8Mjv3VIK2yg8zU6JXLUR6pa4l8/B4ncMlmq0IhadYy DbtYIiAo/HTzcZpIcfwYLUEhwmxxSMZXX/ujntOYz6Qur41bEKz2u+hz90hI77bLU0ox Glfbmmpi5DjGspPUbI+qWfbSo5BVspswlzlmTg3VjNfWiU+EGjIyg1C+QrGjSGpoYZWk 6q6YqhT3ZR712hKt4NuoW9OJjC7IBwtIkOnGS10vZ69knVDMufOxAXv9ETpmRiA61ucM CrMEfDtrquXJ8/68u8CMxIkA6zEyXnMwJIz+qxN42FNkh6vfQU9I87rHJhtk4AJeruNu F2bw== X-Gm-Message-State: APjAAAULD3WcJIg2zx1/lrosd0P4qWKRGXAtUXlOogjhBuuOtsYbQNHW K0Pa8z6KrjSYz0qBqxqaOOdTNA1u X-Google-Smtp-Source: APXvYqwbd0x5puqsTDK9uBiZ57HJdizMEOJ3sIl6xUASjilxu0fgXLZu8FuudXJxzTGXRORjXyGFxA== X-Received: by 2002:a63:fc09:: with SMTP id j9mr6279601pgi.377.1565940185328; Fri, 16 Aug 2019 00:23:05 -0700 (PDT) Received: from [192.168.1.36] (broadband-82-140-193-12.atc.tvcom.ru. [82.140.193.12]) by smtp.googlemail.com with ESMTPSA id h13sm5246240pfn.13.2019.08.16.00.23.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Aug 2019 00:23:04 -0700 (PDT) From: Andriy Gapon Subject: confused/concerned about ZFS / 64-bit atomics / 32-bit platforms To: freebsd-hackers@freebsd.org Openpgp: preference=signencrypt Message-ID: <8bbee981-4f95-22eb-d9ec-00267c8e111d@FreeBSD.org> Date: Fri, 16 Aug 2019 10:23:01 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 468vtM56Mfz3PMg X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of agapon@gmail.com designates 209.85.215.177 as permitted sender) smtp.mailfrom=agapon@gmail.com X-Spamd-Result: default: False [-6.13 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; TO_DN_NONE(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-1.00)[-0.995,0]; FORGED_SENDER(0.30)[avg@FreeBSD.org,agapon@gmail.com]; RECEIVED_SPAMHAUS_PBL(0.00)[12.193.140.82.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[avg@FreeBSD.org,agapon@gmail.com]; TO_DOM_EQ_FROM_DOM(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[FreeBSD.org]; RCPT_COUNT_ONE(0.00)[1]; IP_SCORE(-3.13)[ip: (-9.85), ipnet: 209.85.128.0/17(-3.37), asn: 15169(-2.38), country: US(-0.05)]; RCVD_IN_DNSWL_NONE(0.00)[177.215.85.209.list.dnswl.org : 127.0.5.0]; RCVD_TLS_ALL(0.00)[] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Aug 2019 07:23:08 -0000 I somewhat confused with respect to what guarantees C provides with respect to accessing 64-bit objects on 32-bit platforms, if any. I am also concerned about the use of 64-bit atomic values in ZFS given that FreeBSD seems to support ZFS on 32-bit platforms (powerpc, i386, ...). My concerns stems from a failed import of a ZFS change from illumos. That change has this pattern: volatile uint64_t *p; uint64_t x, y; ... x = *p; ... atomic_foo_64(p, y); Specifically, I am concerned that there can be a torn read in x=*p assignment on 32-bit platforms even if they provide a native implementation of atomic_foo_64(). I am even more concerned about platforms where atomic_foo_64() is not available and we need to emulate it in opensolaris_atomic.c with the help from atomic_mtx. In more general terms, I am concerned about plain reads of 64-bit variables that are manipulated atomically elsewhere, on 32-bit platforms. Is my concern justified? Note that I saw the above access pattern only in the code that is not imported yet. I only suspect that that pattern might already be present in the current ZFS/FreeBSD code given that it uses 64-bit variables and atomics a lot. I am not sure if there is a quick way to check that. Maybe devel/coccinelle could be used for that. -- Andriy Gapon