{"action":"created","comment":{"url":"https://api.github.com/repos/google/ktsan/pulls/comments/36177147","id":36177147,"diff_hunk":"@@ -295,38 +356,40 @@ s16 kt_atomic16_xadd(kt_thr_t *thr, uptr_t pc, uptr_t addr, s16 value)\n \ts16 rv;\n \n \tKT_ATOMIC_OP(rv = kt_atomic16_xadd_no_ktsan((void *)addr, value),\n-\t\t\taddr, kt_memory_order_acq_rel);\n+\t\taddr, kt_memory_order_acq_rel, kt_memory_order_relaxed);\n \n \treturn rv;\n }\n \n-/* FIXME(xairy): doesn't imply memory barrier. */\n void kt_bitop_set_bit(kt_thr_t *thr, uptr_t pc, uptr_t addr, long nr)\n {\n-\tKT_ATOMIC_OP(kt_bitop_set_bit_no_ktsan((void *)addr, nr),\n-\t\t\taddr + nr / 8, kt_memory_order_release);\n+\tKT_ATOMIC_OP(\n+\t\tkt_bitop_set_bit_no_ktsan((void *)addr, nr), addr + nr / 8,\n+\t\tkt_memory_order_relaxed, kt_memory_order_release);\n }\n \n-/* FIXME(xairy): doesn't imply memory barrier. */\n void kt_bitop_clear_bit(kt_thr_t *thr, uptr_t pc, uptr_t addr, long nr)\n {\n-\tKT_ATOMIC_OP(kt_bitop_clear_bit_no_ktsan((void *)addr, nr),\n-\t\t\taddr + nr / 8, kt_memory_order_release);\n+\tKT_ATOMIC_OP(\n+\t\tkt_bitop_clear_bit_no_ktsan((void *)addr, nr), addr + nr / 8,\n+\t\tkt_memory_order_relaxed, kt_memory_order_release);\n }\n \n-/* FIXME(xairy): doesn't imply memory barrier. */\n void kt_bitop_change_bit(kt_thr_t *thr, uptr_t pc, uptr_t addr, long nr)\n {\n-\tKT_ATOMIC_OP(kt_bitop_change_bit_no_ktsan((void *)addr, nr),\n-\t\t\taddr + nr / 9, kt_memory_order_release);\n+\tKT_ATOMIC_OP(\n+\t\tkt_bitop_change_bit_no_ktsan((void *)addr, nr), addr + nr / 8,\n+\t\tkt_memory_order_relaxed, kt_memory_order_acq_rel);\n }\n \n int kt_bitop_test_and_set_bit(kt_thr_t *thr, uptr_t pc, uptr_t addr, long nr)\n {\n \tint rv;\n \n-\tKT_ATOMIC_OP(rv = kt_bitop_test_and_set_bit_no_ktsan((void *)addr, nr),\n-\t\t\taddr + nr / 8, kt_memory_order_acq_rel);\n+\tKT_ATOMIC_OP(\n+\t\trv = kt_bitop_test_and_set_bit_no_ktsan((void *)addr, nr),\n+\t\taddr + nr / 8,","path":"mm/ktsan/sync_atomic.c","position":417,"original_position":417,"commit_id":"23f79d5f294d8046e4659260397b9fca7f8becf2","original_commit_id":"f4c3264a5f62161f2f69fb334483df4e1f4068af","user":{"login":"dvyukov","id":1095328,"avatar_url":"https://avatars.githubusercontent.com/u/1095328?v=3","gravatar_id":"","url":"https://api.github.com/users/dvyukov","html_url":"https://github.com/dvyukov","followers_url":"https://api.github.com/users/dvyukov/followers","following_url":"https://api.github.com/users/dvyukov/following{/other_user}","gists_url":"https://api.github.com/users/dvyukov/gists{/gist_id}","starred_url":"https://api.github.com/users/dvyukov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dvyukov/subscriptions","organizations_url":"https://api.github.com/users/dvyukov/orgs","repos_url":"https://api.github.com/users/dvyukov/repos","events_url":"https://api.github.com/users/dvyukov/events{/privacy}","received_events_url":"https://api.github.com/users/dvyukov/received_events","type":"User","site_admin":false},"body":"if you do that, bitop_test_and_set_bit(p, 0) and bitop_test_and_set_bit(p, 16) will not synchronize with each other\r\nit is wrong, you need to use address of the atomic variable","created_at":"2015-08-04T11:10:35Z","updated_at":"2015-08-04T11:10:35Z","html_url":"https://github.com/google/ktsan/pull/18#discussion_r36177147","pull_request_url":"https://api.github.com/repos/google/ktsan/pulls/18","_links":{"self":{"href":"https://api.github.com/repos/google/ktsan/pulls/comments/36177147"},"html":{"href":"https://github.com/google/ktsan/pull/18#discussion_r36177147"},"pull_request":{"href":"https://api.github.com/repos/google/ktsan/pulls/18"}}},"pull_request":{"url":"https://api.github.com/repos/google/ktsan/pulls/18","id":41503607,"html_url":"https://github.com/google/ktsan/pull/18","diff_url":"https://github.com/google/ktsan/pull/18.diff","patch_url":"https://github.com/google/ktsan/pull/18.patch","issue_url":"https://api.github.com/repos/google/ktsan/issues/18","number":18,"state":"open","locked":false,"title":"Support standalone membars","user":{"login":"xairy","id":4965052,"avatar_url":"https://avatars.githubusercontent.com/u/4965052?v=3","gravatar_id":"","url":"https://api.github.com/users/xairy","html_url":"https://github.com/xairy","followers_url":"https://api.github.com/users/xairy/followers","following_url":"https://api.github.com/users/xairy/following{/other_user}","gists_url":"https://api.github.com/users/xairy/gists{/gist_id}","starred_url":"https://api.github.com/users/xairy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xairy/subscriptions","organizations_url":"https://api.github.com/users/xairy/orgs","repos_url":"https://api.github.com/users/xairy/repos","events_url":"https://api.github.com/users/xairy/events{/privacy}","received_events_url":"https://api.github.com/users/xairy/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-03T19:59:56Z","updated_at":"2015-08-04T11:10:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"905e5d3a848bfb6f091c74f2293515132cf5ae3b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/google/ktsan/pulls/18/commits","review_comments_url":"https://api.github.com/repos/google/ktsan/pulls/18/comments","review_comment_url":"https://api.github.com/repos/google/ktsan/pulls/comments{/number}","comments_url":"https://api.github.com/repos/google/ktsan/issues/18/comments","statuses_url":"https://api.github.com/repos/google/ktsan/statuses/23f79d5f294d8046e4659260397b9fca7f8becf2","head":{"label":"google:tsan-dev","ref":"tsan-dev","sha":"23f79d5f294d8046e4659260397b9fca7f8becf2","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":22620547,"name":"ktsan","full_name":"google/ktsan","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/ktsan","description":"ThreadSanitizer for Linux kernel, a fast data race detector","fork":false,"url":"https://api.github.com/repos/google/ktsan","forks_url":"https://api.github.com/repos/google/ktsan/forks","keys_url":"https://api.github.com/repos/google/ktsan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/ktsan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/ktsan/teams","hooks_url":"https://api.github.com/repos/google/ktsan/hooks","issue_events_url":"https://api.github.com/repos/google/ktsan/issues/events{/number}","events_url":"https://api.github.com/repos/google/ktsan/events","assignees_url":"https://api.github.com/repos/google/ktsan/assignees{/user}","branches_url":"https://api.github.com/repos/google/ktsan/branches{/branch}","tags_url":"https://api.github.com/repos/google/ktsan/tags","blobs_url":"https://api.github.com/repos/google/ktsan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/ktsan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/ktsan/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/ktsan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/ktsan/statuses/{sha}","languages_url":"https://api.github.com/repos/google/ktsan/languages","stargazers_url":"https://api.github.com/repos/google/ktsan/stargazers","contributors_url":"https://api.github.com/repos/google/ktsan/contributors","subscribers_url":"https://api.github.com/repos/google/ktsan/subscribers","subscription_url":"https://api.github.com/repos/google/ktsan/subscription","commits_url":"https://api.github.com/repos/google/ktsan/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/ktsan/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/ktsan/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/ktsan/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/ktsan/contents/{+path}","compare_url":"https://api.github.com/repos/google/ktsan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/ktsan/merges","archive_url":"https://api.github.com/repos/google/ktsan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/ktsan/downloads","issues_url":"https://api.github.com/repos/google/ktsan/issues{/number}","pulls_url":"https://api.github.com/repos/google/ktsan/pulls{/number}","milestones_url":"https://api.github.com/repos/google/ktsan/milestones{/number}","notifications_url":"https://api.github.com/repos/google/ktsan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/ktsan/labels{/name}","releases_url":"https://api.github.com/repos/google/ktsan/releases{/id}","created_at":"2014-08-04T21:26:17Z","updated_at":"2015-07-29T12:07:40Z","pushed_at":"2015-08-04T11:05:26Z","git_url":"git://github.com/google/ktsan.git","ssh_url":"git@github.com:google/ktsan.git","clone_url":"https://github.com/google/ktsan.git","svn_url":"https://github.com/google/ktsan","homepage":"thread-sanitizer.googlecode.com","size":1226958,"stargazers_count":30,"watchers_count":30,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":1,"forks":8,"open_issues":1,"watchers":30,"default_branch":"tsan"}},"base":{"label":"google:tsan","ref":"tsan","sha":"5fa219703603d8da2eb761d77c4a55829b2ff9d5","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":22620547,"name":"ktsan","full_name":"google/ktsan","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/ktsan","description":"ThreadSanitizer for Linux kernel, a fast data race detector","fork":false,"url":"https://api.github.com/repos/google/ktsan","forks_url":"https://api.github.com/repos/google/ktsan/forks","keys_url":"https://api.github.com/repos/google/ktsan/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/ktsan/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/ktsan/teams","hooks_url":"https://api.github.com/repos/google/ktsan/hooks","issue_events_url":"https://api.github.com/repos/google/ktsan/issues/events{/number}","events_url":"https://api.github.com/repos/google/ktsan/events","assignees_url":"https://api.github.com/repos/google/ktsan/assignees{/user}","branches_url":"https://api.github.com/repos/google/ktsan/branches{/branch}","tags_url":"https://api.github.com/repos/google/ktsan/tags","blobs_url":"https://api.github.com/repos/google/ktsan/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/ktsan/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/ktsan/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/ktsan/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/ktsan/statuses/{sha}","languages_url":"https://api.github.com/repos/google/ktsan/languages","stargazers_url":"https://api.github.com/repos/google/ktsan/stargazers","contributors_url":"https://api.github.com/repos/google/ktsan/contributors","subscribers_url":"https://api.github.com/repos/google/ktsan/subscribers","subscription_url":"https://api.github.com/repos/google/ktsan/subscription","commits_url":"https://api.github.com/repos/google/ktsan/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/ktsan/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/ktsan/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/ktsan/issues/comments{/number}","contents_url":"https://api.github.com/repos/google/ktsan/contents/{+path}","compare_url":"https://api.github.com/repos/google/ktsan/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/ktsan/merges","archive_url":"https://api.github.com/repos/google/ktsan/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/ktsan/downloads","issues_url":"https://api.github.com/repos/google/ktsan/issues{/number}","pulls_url":"https://api.github.com/repos/google/ktsan/pulls{/number}","milestones_url":"https://api.github.com/repos/google/ktsan/milestones{/number}","notifications_url":"https://api.github.com/repos/google/ktsan/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/ktsan/labels{/name}","releases_url":"https://api.github.com/repos/google/ktsan/releases{/id}","created_at":"2014-08-04T21:26:17Z","updated_at":"2015-07-29T12:07:40Z","pushed_at":"2015-08-04T11:05:26Z","git_url":"git://github.com/google/ktsan.git","ssh_url":"git@github.com:google/ktsan.git","clone_url":"https://github.com/google/ktsan.git","svn_url":"https://github.com/google/ktsan","homepage":"thread-sanitizer.googlecode.com","size":1226958,"stargazers_count":30,"watchers_count":30,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":8,"mirror_url":null,"open_issues_count":1,"forks":8,"open_issues":1,"watchers":30,"default_branch":"tsan"}},"_links":{"self":{"href":"https://api.github.com/repos/google/ktsan/pulls/18"},"html":{"href":"https://github.com/google/ktsan/pull/18"},"issue":{"href":"https://api.github.com/repos/google/ktsan/issues/18"},"comments":{"href":"https://api.github.com/repos/google/ktsan/issues/18/comments"},"review_comments":{"href":"https://api.github.com/repos/google/ktsan/pulls/18/comments"},"review_comment":{"href":"https://api.github.com/repos/google/ktsan/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/google/ktsan/pulls/18/commits"},"statuses":{"href":"https://api.github.com/repos/google/ktsan/statuses/23f79d5f294d8046e4659260397b9fca7f8becf2"}}}}